Backblaze B2 Python



  1. Wasabi Vs Backblaze B2
  2. Backblaze B2 Python
  3. Backblaze B2 Python Download
  4. Backblaze B2 Python Tutorial

Welcome to Backblaze’s unofficial documentation! This is a unofficial asynchronous & synchronous wrapper for Backblaze’s B2 API. Features: Full API coverage. Background authentication. Asynchronous & synchronous support. Easy to use with an object oriented design. 100% test coverage. Upload URL caching. Install pip3 install backblaze. Tagged with backblaze b2, python « Forward SMS to multiple phone numbers with TwiML Bin. Authenticate with BackBlaze B2 and list buckets with Python. Install from this repo, or install from PyPi: pip install django-backblaze-b2 As tested, requires python 3.6 or greater but solely due to type annotations.

I have been trying to upload files to backblaze through API using python. The following is the code snippet I used. Import json import urllib2 import hashlib uploadurl = ' # Provided by b2getuploadurl uploadauthorizationtoken = ' # Provided by b2getuploadurl filedata = 'Now, I am become Death, the destroyer of worlds.' Devel/b2: NEW PORT - Command Line Interface for Backblaze's B2 storage service B2 Cloud Storage is a cloud service for storing files in the cloud. Files are available for download at any time, either through the API or through a browser-compatible URL.

Package Details: backblaze-b2 2.3.0-3

Package Actions

  • View PKGBUILD / View Changes
Git Clone URL: https://aur.archlinux.org/backblaze-b2.git (read-only, click to copy)
Package Base: backblaze-b2
Description: Backblaze B2 Command Line Client
Upstream URL: https://github.com/Backblaze/B2_Command_Line_Tool
Keywords:
Licenses: MIT
Submitter: 2bluesc
Maintainer: 2bluesc
Last Packager: 2bluesc
Votes: 20
Popularity: 0.062057
First Submitted: 2015-10-29 06:31
Last Updated: 2021-04-04 17:44

Dependencies (9)

  • python(python-dbg)
  • python-b2sdk<2.0.0
  • python-rst2ansi=0.1.5
  • python-class-registry=3.0.5
  • python-docutils>=0.16
  • python-arrow>=0.8.0
  • python-b2sdk>=1.0.0
  • python-setuptools(make)
  • python-setuptools-scm<6.0 (make)

Sources (1)

Kage-Yami commented on 2021-04-04 17:46

2bluesc commented on 2021-04-04 17:44

Kage-Yami commented on 2021-04-04 17:38

Looks like the same issue as we found on python-b2sdk is affecting this package as well; turns out the timing of my builds were such that the new version of this wasn't visible yet when I originally reported, but a later build then failed.

Same pip error:

ipha commented on 2021-04-04 14:49

New dep python-docutils is needed as of version 2.2+

Hoek commented on 2020-10-17 16:24

@2bluesc sorry I was mistaken. Somehow building the package using yay caused the build to error out because python-tqdm and python-logfury were missing, but I see they're in the package dependencies.I can't reproduce after reinstalling, everything seems to be fine :/

2bluesc commented on 2020-10-16 04:04

@hoek Could you elaborate on what dependencies are missing?

Backblaze b2 python programming

The dependencies in the upstream project are @ https://github.com/Backblaze/B2_Command_Line_Tool/blob/master/requirements.txt and are covered by this package and/or the b2sdk package.

And as always, patches to fix the issue(s) are welcome.

Hoek commented on 2020-10-15 16:20

@2bluesc could you please add the mentioned packages to the deps, this package is awesome, but broken for a year already :(

FabioLolix commented on 2020-03-19 00:14

@arichiardi your problem is with 'tageditor' not with 'backblaze-b2', by the way 'reflective-rapidjson' is in the AUR

arichiardi commented on 2020-03-18 21:35

Hi there, is anybody running into this one?

Building tageditor...> Making package: tageditor 3.3.4-1 (Wed 18 Mar 2020 02:36:32 PM PDT)> Checking runtime dependencies...> Checking buildtime dependencies...> Missing dependencies: -> reflective-rapidjson> ERROR: Could not resolve all dependencies.

JohnRobson commented on 2020-01-24 06:04

Must install the dependencies: python-b2sdk python-logfury python-funcsigs

Latest version

Released:

A Django app to use backblaze b2 as storage.

Wasabi Vs Backblaze B2

Project description

A storage backend for Django that uses Backblaze's B2 APIs.

Backblaze B2 Python

Implementation wraps Official Python SDK

How to use

  1. Install from this repo, or install from PyPi: pip install django-backblaze-b2As tested, requires python 3.6 or greater but solely due to type annotations. PRs welcome :)
  2. Configure your django settings. The absolute minimum config would be:

Theoretically you may now refer to the base storage class as a storage class.
e.g.

Caching

Because the SDK will authorize/request with the b2 server to retrieve file info, the library caches these account information lookups.
By default, the accountInfo configuration uses a cache by the name of django-backblaze-b2 which you must have in your CACHES section of your settings.py. This is the recommended caching implementation as it leverages the django framework and with that comes thread-safety. You can then use whichever cache implementation you want. It is not recommended to cache with the default django cache, as the clear() method may be called during the backblaze lifecycle.
If you do not wish to use this, you can use a sqlite database on disk for caching, or use a non-thread-safe in-memory implementation. This is only recommended for single-threaded deployments. (remember in most deployments a new thread serves each request).

Public/Logged-In/Private storage

  1. Add django_backblaze_b2 to your INSTALLED_APPS
  2. Add the urls to your urlpatterns in the root urls.py:

Configurations

You may want to use your own bucket name, or set further configuration such as lazy authorization/validation, or specifying file metadata.
Refer to the options for all options.
You can modify the settings dict, but additionally override any setting with the opts keyword argument to the storage classes.

To specify different buckets to use for your public, logged-in, staff storage, you can set thespecificBucketNames attribute of the settings dict.

Why

There are several Django storage packages out there already which support B2, but none met my needs. These are:

  • django-storages
    • Large community engagement ✅
    • Well-tested ✅
    • Second-class support via Apache Libcloud ❌
    • Disconnect in configuration and actual use ❌
    • PR list with low turnaround ❌
  • django-b2
    • Similar aim to this project, around official backblaze SDK ✅
    • Mixed goals (storage, scripts) ❌
    • Tests?? ❌
  • django-backblazeb2-storage
    • Simple configuration ✅
    • Not based around python SDK (potentially harder to keep up with version changes) ❌
    • Tests?? ❌

S3 Compatible API

Backblazed can be used with an S3-compatible APIThis is great, but most packages use an older version of the S3 Api (v2). Backblaze uses v4.

Backblaze b2 calculator

What this package offers

  • Type Annotations
  • Tested
  • No hacks required to get up and running around API deficiencies (any hacks are not exposed in API)
  • Support for public/private files, restricted via Django user permissions
  • Support for CDN and cached url details

How it works

  • A simple implementation of the django.core.files.storage.Storage class provides handling for storage behaviour within your Django application
  • Three url routes are appended to the root of your application:
    1. /b2/
    2. /b2l/
    3. /b2s/These routes act as a proxy/intermediary between the requester and backblaze b2 apis. The public /b2/ allows exposing files from a private bucket, and the logged-in and staff routes will perform the known validations of a django app to prevent unauthorized access.
  • If you use a CDN config, you can specify the CDN options and then include the bucket url segments (/file/<bucket-name>/) if your CDN is proxying the classic b2 url (e.g. f000.backblazeb2.com) or not, if you are proxying the s3-compatible url.

Gotchas

  • The original filename + any upload paths is stored in the database. Thus your column name must be of sufficient length to hold that (unchanged behaviour from FileSystemStorage)
  • When retrieving files from the PublicStorage, LoggedInStorage or StaffStorage, you may not override the 'bucket' or authorization options, or else when the app proxies the file download, it will be unable to retrieve the file from the respective bucket.
  • Simply using LoggedInStorage or StaffStorage is not enough to protect your files if your bucket is not public. If any individual gains access to the file ids/urls for these files, there is no authentication around them. It is up to the implementer to ensure the security of their application.
  • Once the file is uploaded, and someone obtains a file url (e.g. http://djangodomain.com/b2l/uploads/image.png), the django model is no longer involved in file resolution. This means that if you share the bucket between multiple use-cases, you could in theory find files that don't belong to your django app (e.g. some image2.png), or similarly if you delete/change your models, the files could still be downloaded. Consider using an app like django-cleanup if this is important to you

Contributing

Contributions welcome!

  • Please ensure test coverage does not decrease in a meaningful way.
  • Ensure formatting is compliant (make lint)
  • Use conventional commits

Setting up for development

Requires

Backblaze B2 Python
  • python
  • pyenv - align local version
  • GNU Make
  • (optional) docker - run sample app

Version compatibility reminder

VerStatusEOL
3.9bugfix2025-10
3.8bugfix2024-10
3.7security2023-06-27
3.6security2021-12-23

Running

  1. make setup
Python
  • You can run django with make run-django to test django app.
  • You can run tests with make test
  • You can view test coverage with make test-coverage, then see in the terminal,open test/htmlcov/index.htmlor use cov.xml in your favourite IDE like VSCode

Releasing

  1. make publish-to-pypi

Cleanup

  1. make cleanup

Release historyRelease notifications | RSS feed

2.2.1

2.2.0

2.1.1

2.0.0

1.2.0

1.1.3

Backblaze B2 Python

1.1.2

1.1.1

1.1.0

1.0.1

1.0

Download files

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

Backblaze B2 Python Download

Files for django-backblaze-b2, version 2.2.1
Filename, sizeFile typePython versionUpload dateHashes
Filename, size django_backblaze_b2-2.2.1-py3-none-any.whl (16.4 kB) File type Wheel Python version py3 Upload dateHashes
Filename, size django-backblaze-b2-2.2.1.tar.gz (16.9 kB) File type Source Python version None Upload dateHashes
Close

Hashes for django_backblaze_b2-2.2.1-py3-none-any.whl

Hashes for django_backblaze_b2-2.2.1-py3-none-any.whl
AlgorithmHash digest
SHA256400566e913248066a7a0f2426de2a466be830e7d514f038a5ea796f9db284c01
MD5f2fe5728a9ccb73e569228aa8c784c9d
BLAKE2-2566a0b5d8112edabf49bcf02d5ae1d0a774af745a0004e7f92d496eac55fdaad0a
Close

Hashes for django-backblaze-b2-2.2.1.tar.gz

Backblaze B2 Python Tutorial

Hashes for django-backblaze-b2-2.2.1.tar.gz
AlgorithmHash digest
SHA2566d94726dd51adfd425bf327d5c40632628b9dbd5af26c43d592fa8ee8c51232e
MD5fbcd126b6704030e6b68325d9e81e664
BLAKE2-256403f3dc7da47129bf134a1ed16d3d2e69228dca21de3f0fd69520ca3e9ba17f5