Code Monkey home page Code Monkey logo

backblaze-b2's Introduction

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')

backblaze-b2's People

Contributors

acidburn23 avatar ghost93 avatar hermogenesbatista avatar hmhrex avatar mtingers avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.