Skip to main content

django backblaze b2 storage using b2sdk

Project description

https://badge.fury.io/py/django-b2.svg https://travis-ci.org/pyutil/django-b2.svg?branch=master https://codecov.io/gh/pyutil/django-b2/branch/master/graph/badge.svg

django backblaze b2 storage using b2sdk (b2sdk is official backblaze python library)

Documentation

The full documentation is at https://django-b2.readthedocs.io.

Quickstart

Install django-b2:

pip install django-b2

Add into your settings:

MEDIA_URL = '/media/'
DEFAULT_FILE_STORAGE = 'django_b2.storage.B2Storage'
B2_APP_KEY_ID=000xxxxxxxxxxxx000000000n
B2_APP_KEY=keyvalue
B2_BUCKET_NAME=bucketname
# optional, see Usage:
MEDIA_ROOT = ..
B2_LOCAL_MEDIA = ..  # "", "M", "L", "ML"

Using outside of Django:

from django_b2.backblaze_b2 import BackBlazeB2
b2 = BackBlazeB2()
b2.authorize("production", application_key_id, application_key)
b2.set_bucket(bucket_name)
with open(filename, 'rb') as f:
    b2.upload_file(filename, f)
content = b2.download_file(filename)
with open(filename2, 'wb') as f:
    f.write(content)

Features

  • Django media storage (with storage.py) or general python access to BackBlaze B2 (without usage of storage.py).

  • Upload single file to B2 (call backblaze_b2.py as script; new in 0.2.0)

  • Backup a postgres database to B2 (use script pgtob2.sh; new in 0.2.0)

  • Optionally cache media files locally for immediate access or for long time faster access.

Running Tests

Does the code actually work?

source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install -r requirements_test.txt
(myenv) $ tox

Credits

Tools used in rendering this package:

History

0.4.0 (2020-02-10)

  • older local media (see B2_LOCAL_MEDIA) can be cleared with management command b2_clear_local_media

  • B2_LOCAL_CACHE setting renamed to B2_LOCAL_MEDIA, possible values changed to =”ML”

0.3.0 (2020-02-08) - do not use

  • !! new B2_LOCAL_MEDIA setting was in 0.3.0 named incompatible as B2_LOCAL_CACHE=”FM”

  • B2_LOCAL_MEDIA setting to make a local copy of files. So you can have local instances backuped on backblaze.

  • B2_LOCAL_MEDIA prevents failures if the django application want immediately reopen the file (imagekits creating thumbnails, Wagtail is an example)

0.2.0 (2020-01-31)

  • backblaze_b2.py can be called as script to upload single file.

  • pgtob2.sh script to backup postgres database

0.1.5 (2020-01-02)

  • No code change. Minor docs changes.

0.1.4 (2020-01-02)

  • First release on PyPI.

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

django-b2-0.4.1.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

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

django_b2-0.4.1-py2.py3-none-any.whl (12.7 kB view details)

Uploaded Python 2Python 3

File details

Details for the file django-b2-0.4.1.tar.gz.

File metadata

  • Download URL: django-b2-0.4.1.tar.gz
  • Upload date:
  • Size: 13.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.5rc1

File hashes

Hashes for django-b2-0.4.1.tar.gz
Algorithm Hash digest
SHA256 eb5e1a744c1ddbf5b97fb6271323aebbe423f5d5cff95e6dcbb2c996d0e47893
MD5 8112ae920f84a85882b7a80fac21583b
BLAKE2b-256 73a0d25f7751e101b4f55a6509f5b9d69cb1823aa1fbe40fe2e795f5ccc3648b

See more details on using hashes here.

File details

Details for the file django_b2-0.4.1-py2.py3-none-any.whl.

File metadata

  • Download URL: django_b2-0.4.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 12.7 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.5rc1

File hashes

Hashes for django_b2-0.4.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 8bd1e0d3b5d492c6910358a9b9a9f3b7f85531c39bdf3da2d071b43873124fd0
MD5 4be7e7772e9806e5036c788a22398d3b
BLAKE2b-256 e79b354576774d1c5d465cc57d3ce6b3de0b72147e8a19647aa5a4bd2255167e

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