Skip to main content

Lightweight B2 client with backblaze support

Project description

from lightweight_b2.core.b2_client import B2Clientfrom ctypes import pythonapi

    ___       __    __                _       __    __     __   ___ 
   / (_)___ _/ /_  / /__      _____  (_)___ _/ /_  / /_   / /_ |__ \
  / / / __ `/ __ \/ __/ | /| / / _ \/ / __ `/ __ \/ __/  / __ \__/ /
 / / / /_/ / / / / /_ | |/ |/ /  __/ / /_/ / / / / /_   / /_/ / __/ 
/_/_/\__, /_/ /_/\__/ |__/|__/\___/_/\__, /_/ /_/\__/  /_.___/____/ 
    /____/                          /____/                                

lightweight-b2

Ultra-lightweight B2 client. Memory leakage not implemented yet (unlike boto3)

pip install lightweight-b2

Supports:

  • sending existing files
  • sending string as zipped json (data sinks)
  • Operates within a session refreshed every four hours; be sure to shut down the client when you’re done.
Usage Create StorageConnectionParameters:
from lightweight_b2 import StorageConnectionParameters

storage_connection_parameters = StorageConnectionParameters(
    backblaze_access_key_id='access_key_id',
    backblaze_secret_access_key='secret_access_key',
    backblaze_endpoint_url='endpoint_url',
    backblaze_bucket_name='bucket_name'
)

Or just put em into the .env file. Load the .env using load_dotenv()
StorageConnectionParameters() will read all of parameters in format:

BACKBLAZE_ACCESS_KEY_ID=  
BACKBLAZE_SECRET_ACCESS_KEY=  
BACKBLAZE_ENDPOINT_URL=  
BACKBLAZE_BUCKET_NAME=  

or

AZURE_BLOB_PARAMETERS_WITH_KEY=  
AZURE_CONTAINER_NAME=

then:

load_dotenv(env_path)
storage_connection_parameters = StorageConnectionParameters()
b2_client = B2Client(storage_connection_parameters)

b2_client.upload_existing_file(file_path='C:/JohnnySins/Documents/SomeFile.csv')

b2_client.upload_zipped_jsoned_string(
    data='{some_sophisticated_data....}',
    file_name='some_csv_name.csv'
)

b2_client.shutdown()
Sample Main And the final sample main.py would look like:
from lightweight_b2 import B2Client, StorageConnectionParameters


if __name__ == '__main__ ':

    storage_connection_parameters = StorageConnectionParameters(
        backblaze_access_key_id='access_key_id',
        backblaze_secret_access_key='secret_access_key',
        backblaze_endpoint_url='endpoint_url',
        backblaze_bucket_name='bucket_name'
    )

    """
    Or just put em into the .env file. Load the .env using:
    
            load_dotenv(env_path)
    
    and then read it using:
    
            storage_connection_parameters = StorageConnectionParameters()
    """

    b2_client = B2Client(storage_connection_parameters)

    b2_client.upload_existing_file(file_path='C:/JohnnySins/Documents/SomeFile.csv')

    b2_client.upload_zipped_jsoned_string(
        data='some_sophisticated_data....',
        file_name='some_csv_name.csv'
    )

    b2_client.shutdown()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lightweight_b2-0.0.1.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lightweight_b2-0.0.1-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file lightweight_b2-0.0.1.tar.gz.

File metadata

  • Download URL: lightweight_b2-0.0.1.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.4

File hashes

Hashes for lightweight_b2-0.0.1.tar.gz
Algorithm Hash digest
SHA256 f086201129982b50b26ae87ffeae114dbf54bd6136cad3917e3eb7ed627bb489
MD5 490ccd55f96234fa3318315de27481c0
BLAKE2b-256 74984976dfa330fc13fee16048ea169c27610dae68c7e98bf5bf85d41279d9fd

See more details on using hashes here.

File details

Details for the file lightweight_b2-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: lightweight_b2-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.4

File hashes

Hashes for lightweight_b2-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5695897444ddbdccca9cee01558b96e7cea3598bf5fc2bfe53723f51a522eb45
MD5 bf79e34c7c8061dea1b1d7f506ea5626
BLAKE2b-256 efc09fcdf6f9fc6e00e1ae43819737831c73122062d8c7661de848fbcc4a8891

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page