django-blob-storage
This is a fork from django-db-storage2
Overview
Warning: In many cases, storing files in the database is a BAD idea. Your database will easily become bloated and the performance can degrade rapidly. See this StackExchange post_ for more information.
.. _StackExchange post: http://programmers.stackexchange.com/questions/150669/is-it-a-bad-practice-to-store-large-files-10-mb-in-a-database
This is a custom storage backend for storing files in the database instead of the file system and is a drop-in replacement for Django's FileSystemStorage. Some benefits of this application:
- no changes needed to existing models, it just works (and if it doesn't, open a ticket!)
- django-admin is implemented and can be used to search, upload, download and manage files
- 100% code coverage with unit tests
- only db files need to be backed up
Requirements
- Python (3.5+)
- Django (3.2+)
Installation
Installation using pip::
$ pip install django-blob-storage
Update settings.py
# Add 'dbstorage' to INSTALLED_APPS
INSTALLED_APPS = [
'dbstorage',
]
# Optionally set DEFAULT_FILE_STORAGE
DEFAULT_FILE_STORAGE = 'dbstorage.storage.DBStorage'
# Optionally for tracking file accesses (currently over view)
# DJANGO_DBFILE_TRACK_ACCESSED=True
# Optionally set another db than default
# DJANGO_DBFILE_DB = "foo"
# Choose a root url for uploaded files
MEDIA_URL = '/media/'
Update urls.py
urlpatterns = [
...
# dbstorage
path("", include("dbstorage.urls")),
]
Run database migrations (done automatically, when included as app)
env DJANGO_SETTINGS_MODULE=tests.settings PYTHONPATH="." poetry run django-admin migrate
How to Use
No modification are needed for models to work properly.
def user_directory_path(instance, filename):
return 'user_{0}/{1}'.format(instance.user.id, filename)
class MyModel(models.Model):
file_field1 = models.FileField()
file_field2 = models.FileField(upload_to='uploads/%Y/%m/%d/')
file_field3 = models.FileField(upload_to=user_directory_path)
Bugs?
Create an issue at https://github.com/devkral/django-blob-storage/issues
Metadata
Release files for django-blob-storage 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django_blob_storage-0.2.2.tar.gz | 7.1 kB | Without provenance | Details for django_blob_storage-0.2.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_blob_storage-0.2.2-py3-none-any.whl | Python 3 | none | any | Details for django_blob_storage-0.2.2-py3-none-any.whl |
Total release size: 16.0 kB
Release files / django_blob_storage-0.2.2.tar.gz
| Download URL | django_blob_storage-0.2.2.tar.gz |
|---|---|
| Size | 7.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9169cea60749947426fa9f7fea462caf7689764b3e90b15a507bbba5bcdb9a2d
|
|
BLAKE2b-256 checksum How to use checksums |
2b214f62515414984d88521ef2216c5c94927efb01b4632c5cea9c3fa4af3c40
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.2 CPython/3.11.3 Linux/6.3.2-arch1-1
|
Release files / django_blob_storage-0.2.2-py3-none-any.whl
| Download URL | django_blob_storage-0.2.2-py3-none-any.whl |
|---|---|
| Size | 8.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9f2eddb68d6b0dafb4a44c3fb1d8acdb5d35ebbc169dfec6a40e380be1941139
|
|
BLAKE2b-256 checksum How to use checksums |
6a136526f907c0f54f58d5228e7689b75ae2d569f85c09c67fc56f1eb2f9a4e1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.2 CPython/3.11.3 Linux/6.3.2-arch1-1
|
Security for django-blob-storage 0.2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.