https://github.com/mtingers/backblaze-b2
Python module for accessing the Backblaze B2 API
https://github.com/mtingers/backblaze-b2
backblaze backblaze-api backblaze-b2 backblaze-storage-service
Last synced: 8 months ago
JSON representation
Python module for accessing the Backblaze B2 API
- Host: GitHub
- URL: https://github.com/mtingers/backblaze-b2
- Owner: mtingers
- License: mit
- Created: 2015-12-18T19:32:52.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2018-08-10T17:06:04.000Z (almost 8 years ago)
- Last Synced: 2025-04-06T04:41:18.533Z (about 1 year ago)
- Topics: backblaze, backblaze-api, backblaze-b2, backblaze-storage-service
- Language: Python
- Size: 40 KB
- Stars: 39
- Watchers: 5
- Forks: 18
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
backblaze-b2
============
Python module for accessing the Backblaze B2 API
Examples
-----
from backblazeb2 import BackBlazeB2
b2 = BackBlazeB2(account_id, app_key)
# Upload an entire directory concurrently, encrypt with a password
b2.recursive_upload('/path/to/foobar', bucket_name='my-bucket', multithread=True, password='p@ssW0rdz')
# Upload a single file without a password
b2.upload_file('/path/to/file.txt', bucket_name='baz')
# Upload a single file, password encrypted, then download & decrypt
b2.upload_file('/path/to/secrets.txt', bucket_name='baz', password='supersecret')
response = b2.download_file_by_name('/path/to/myfile.txt', 'savedfile.txt', password='supersecret')
# List all of your buckets
buckets = b2.list_buckets()
# Create a bucket
response = b2.create_bucket('new-bucket', bucket_type='allPrivate')
# Download a file by name
response = b2.download_file_by_name('/path/to/myfile.txt', 'savedfile.txt')
# Authorize download for a private file
bucket_id = "" # Id of bucket which you want authorize download file
bucket_name = "" # Verbose name of bucket
file_name_prefix = ""
url_authorized_download = b2.get_download_authorization(
bucket_id=bucket_id, bucket_name=bucket_name,
file_name_prefix=file_name_prefix)
# The response some looks like this:
# https://f345.backblazeb2.com/file/photos/cute/kitten.jpg?Authorization=3_20160803004041_53982a92f631a8c7303e3266_d940c7f5ee17cd1de3758aaacf1024188bc0cd0b_000_20160804004041_0006_dnld
# Download with authorized url
b2.download_file_with_authorized_url(url_authorized_download, 'file_name.log')