django backblaze b2 storage using b2sdk
Project description
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
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)
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.3.0 (2020-02-08)
B2_LOCAL_CACHE setting to make a local copy of files. So you can have local instances backuped on backblaze.
B2_LOCAL_CACHE 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django_b2-0.3.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e12c8677ae481ca3b3f2ed42474c287359fd363b0606431c5a6df0d0ed4cdbd3 |
|
MD5 | 33a1bfe7bed1f0d833f8c78c64ef8b31 |
|
BLAKE2b-256 | 56de1468567f8b8f0e56699f5994890583da458e9a337160f898b722e06ad403 |