django-upstorage-backend
This is a custom django storage backend for UpStorage
Installation
- Install Library Using
pip
>> pip install django-upstorage-backend
Starting Guide
- Set The Custom Storage Backend. Now Open settings.py of your project.
DEFAULT_FILE_STORAGE = 'django-upstorage-backend.storages.backends.U3Storage'
- Set some required KEYS to
settings.py
AUTH_TOKEN = 'auth token from your account'
API_KEY = 'api key of your project'
USERNAME = 'username of your account'
PROJECT_NAME = 'Created Project name'
Thats it, We are all done. Now all of your files will be handeled by the custom UpStorage's Backend Storage.
Advanced Guide
-
You don't need to set 'upload_to' in model Fields (Defaultly it files will be saved on the root of your project.) -
File Link Will Be Stored On Your Model As Expected.You Can call them as you do usally. -
You Can also set 'upload_to='specific/folder' in your model like:Class TestModel(model.Model): image = models.ImageField(upload_to='to/my/folder') # this will save the file to that folder.if there's no folder it will create it.
-
If you want to delete the image from the UpStorage Bucket when you delete it from django, you have to do it a bit differently.Lemme show youClass TestModel(model.Model): image = models.ImageField() # To delete the image you have to delete that by writing: obj = TestModel.objects.get(id=pk) obj.image.delete() # You can't directly delete it like this: obj.delete() # this won't delete the file from UpStorage # You have to delete the file field first to delete it.
To make it simple you can override
deleteMethod on your ModelClass TestModel(model.Model): image = models.ImageField() def delete(self): self.image.delete() super(TestModel, self).delete()
Metadata
Release files for django-upstorage-backend 1.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-upstorage-backend-1.2.tar.gz | 4.5 kB | Without provenance | Details for django-upstorage-backend-1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_upstorage_backend-1.2-py3-none-any.whl | Python 3 | none | any | Details for django_upstorage_backend-1.2-py3-none-any.whl |
Total release size: 9.9 kB
Release files / django-upstorage-backend-1.2.tar.gz
| Download URL | django-upstorage-backend-1.2.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
36372c94118aa0fff4a6878d32589b4d685bb881b24b470ab4f0c7a20e6114e2
|
|
BLAKE2b-256 checksum How to use checksums |
840e83e3d7d80d65e7a6ae5802318e42869218a625526c8780b016fdb5bf093c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5
|
Release files / django_upstorage_backend-1.2-py3-none-any.whl
| Download URL | django_upstorage_backend-1.2-py3-none-any.whl |
|---|---|
| Size | 5.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1863f2e84f0b5dff50d42f3e1c2c3f57e3fda088d6e1d873f08bdb97e19b9081
|
|
BLAKE2b-256 checksum How to use checksums |
3287978ae96233e41433f75479b53b6d6a3a52d7fec182c9a31fcdb6b41ef2e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5
|
Security for django-upstorage-backend 1.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.