Store Django file-uploads on the Interplanetary File System.
Uploads are added and pinned to the configured IPFS node, which returns the IPFS Content ID (a hash of the contents). This hash is the name that is saved to your database. Duplicate content will also have the same address, saving disk space.
Because of this only file creation and reading is supported.
Other IPFS users access and reseed a piece of content through its unique content ID. Differently-distributed (i.e. normal HTTP) users can access the uploads through an HTTP→IPFS gateway.
Installation
pip install django-ipfs-storage
Configuration
By default ipfs_storage adds and pins content to an IPFS daemon running on localhost and returns URLs pointing to the public https://ipfs.io/ipfs/ HTTP Gateway
To customise this, set the following variables in your settings.py:
IPFS_STORAGE_API_URL: defaults to 'http://localhost:5001/api/v0/'.
IPFS_GATEWAY_API_URL: defaults to 'https://ipfs.io/ipfs/'.
Set IPFS_GATEWAY_API_URL to 'http://localhost:8080/ipfs/' to serve content through your local daemon’s HTTP gateway.
Usage
There are two ways to use a Django storage backend.
As default backend
Use IPFS as Django’s default file storage backend:
# settings.py
DEFAULT_FILE_STORAGE = 'ipfs_storage.InterPlanetaryFileSystemStorage'
IPFS_STORAGE_API_URL = 'http://localhost:5001/api/v0/'
IPFS_STORAGE_GATEWAY_URL = 'http://localhost:8080/ipfs/'
For a specific FileField
Alternatively, you may only want to use the IPFS storage backend for a single field:
from django.db import models
from ipfs_storage import InterPlanetaryFileSystemStorage
class MyModel(models.Model):
# …
file_stored_on_ipfs = models.FileField(storage=InterPlanetaryFileSystemStorage())
other_file = models.FileField() # will still use DEFAULT_FILE_STORAGE
Don’t forget the brackets to instantiate InterPlanetaryFileSystemStorage() with the default arguments!
FAQ
Why IPFS?
Not my department. See https://ipfs.io/#why.
How do I ensure my uploads are always available?
I don’t know. Maybe look into using ipfs-cluster to spread it across a few nodes? Or perhaps you could integrate Eternum’s hosted pinning service.
How do I backup my uploads?
See above.
How do I delete an upload?
Because of the distributed nature of IPFS, anyone who accesses a piece of content keeps a copy, and reseeds it for you automatically until it’s evicted from their node’s local cache. Yay bandwidth costs! Boo censorship!
Unfortunately, if you’re trying to censor yourself (often quite necessary), this means the best we can do is unpin the piece of content from your own IPFS node(s) and hope nobody else has pinned it.
How do I securely expose my IPFS daemon’s API to connect remotely?
Someone please tell me.
How do I securely expose my own IPFS←HTTP Gateway?
Again, see above.
Metadata
Release files for django-ipfs-storage 0.0.4
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-ipfs-storage-0.0.4.tar.gz | 4.3 kB | Without provenance | Details for django-ipfs-storage-0.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_ipfs_storage-0.0.4-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for django_ipfs_storage-0.0.4-py2.py3-none-any.whl |
Total release size: 10.9 kB
Release files / django-ipfs-storage-0.0.4.tar.gz
| Download URL | django-ipfs-storage-0.0.4.tar.gz |
|---|---|
| Size | 4.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dc978f0416cb7a9fb18d09021d2064bac1e418da55db5285733931a1bce75bfa
|
|
BLAKE2b-256 checksum How to use checksums |
347ab69d57d382ae31c438b16a65a6e448305372446a4cb025ef565ca4ec1339
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / django_ipfs_storage-0.0.4-py2.py3-none-any.whl
| Download URL | django_ipfs_storage-0.0.4-py2.py3-none-any.whl |
|---|---|
| Size | 6.7 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
20783f09ccde8f7c944a3e5bab39ad19397fb6fda59c9095d2c7d4635336675f
|
|
BLAKE2b-256 checksum How to use checksums |
12ec0cb14649bf8f196bbd2299d2076a051fe09cb73704f9e15f356d31f4c884
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django-ipfs-storage 0.0.4
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.