Skip to main content

django-chunk-upload

This simple django app enables users to upload large files to Django in multiple chunks, with the ability to resume if the upload is interrupted.

The most of the code base belongs to django-chunked-upload of juliomalegria and I would like to thank him for this awesome package.

This app is intented to work with JQuery-File-Upload by Sebastian Tschan (documentation).

License: MIT-Zero.

Demo

If you want to see a very simple Django demo project using this module, please take a look at django-chunk-upload-demo.

Installation

Install via pip:

pip install django-chunk-upload

And then add it to your Django INSTALLED_APPS:

INSTALLED_APPS = (
    # ...
    'django_chunk_upload',
)

Typical usage

  1. An initial POST request is sent to the url linked to ChunkUploadView (or any subclass) with the first chunk of the file. The name of the chunk file can be overriden in the view (class attribute field_name). Example:

{"my_file": <File>}
  1. In return, server with response with the upload_id, the current offset and the when will the upload expire (expires). Example:

{
    "upload_id": "5230ec1f59d1485d9d7974b853802e31",
    "offset": 10000,
    "expires": "2013-07-18T17:56:22.186Z"
}
  1. Repeatedly POST subsequent chunks using the upload_id to identify the upload to the url linked to ChunkUploadView (or any subclass). Example:

{
    "upload_id": "5230ec1f59d1485d9d7974b853802e31",
    "my_file": <File>
}
  1. Server will continue responding with the upload_id, the current offset and the expiration date (expires).

  2. Finally, when upload is completed, a POST request is sent to the url linked to ChunkUploadCompleteView (or any subclass). This request must include the upload_id and the md5 checksum (hex). Example:

{
    "upload_id": "5230ec1f59d1485d9d7974b853802e31",
    "md5": "fc3ff98e8c6a0d3087d515c0473f8677"
}
  1. If everything is OK, server will response with status code 200 and the data returned in the method get_response_data (if any).

Possible error responses:

  • User is not authenticated. Server responds 403 (Forbidden).

  • Upload has expired. Server responds 410 (Gone).

  • upload_id does not match any upload. Server responds 404 (Not found).

  • No chunk file is found in the indicated key. Server responds 400 (Bad request).

  • Request does not contain Content-Range header. Server responds 400 (Bad request).

  • Size of file exceeds limit (if specified). Server responds 400 (Bad request).

  • Offsets does not match. Server responds 400 (Bad request).

  • md5 checksums does not match. Server responds 400 (Bad request).

Settings

Add any of these variables into your project settings to override them.

DJANGO_CHUNK_UPLOAD_EXPIRATION_DELTA

  • How long after creation the upload will expire.

  • Default: datetime.timedelta(days=1)

DJANGO_CHUNK_UPLOAD_PATH

  • Path where uploading files will be stored until completion.

  • Default: 'chunk_uploads/%Y/%m/%d'

DJANGO_CHUNK_UPLOAD_TO

  • upload_to to be used in the Model’s FileField.

  • Default: DJANGO_CHUNK_UPLOAD_PATH + '/{{ instance.upload_id }}.part'

DJANGO_CHUNK_UPLOAD_STORAGE_CLASS

  • Storage system (should be a class).

  • Default: None (use default storage system)

DJANGO_CHUNK_UPLOAD_ABSTRACT_MODEL

DJANGO_CHUNK_UPLOAD_NULL_USER

  • Boolean that defines whether the “user” field of ChunkUpload model can be NULL or not

  • Default: True

DJANGO_CHUNK_UPLOAD_ENCODER

  • Function used to encode response data. Receives a dict and returns a string.

  • Default: DjangoJSONEncoder().encode

DJANGO_CHUNK_UPLOAD_CONTENT_TYPE

  • Content-Type for the response data.

  • Default: 'application/json'

DJANGO_CHUNK_UPLOAD_MAX_BYTES

  • Max amount of data (in bytes) that can be uploaded. None means no limit.

  • Default: None

Support

If you find any bug or you want to propose a new feature, please use the issues tracker. I’ll be happy to help you! :-)

Metadata

Release files for django-chunk-upload 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-chunk-upload 2.0.0
File Size Uploaded Provenance
django-chunk-upload-2.0.0.tar.gz 10.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for django-chunk-upload 2.0.0
File Interpreter ABI Platform
django_chunk_upload-2.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 21.7 kB

Release files / django-chunk-upload-2.0.0.tar.gz

Download URL django-chunk-upload-2.0.0.tar.gz
Size 10.4 kB
Tags Source
SHA-256 checksum
How to use checksums
b66ffdb19f2fd9cd58b3a493c75db98531263e5444450e48f76f1ac6b2516f1b
BLAKE2b-256 checksum
How to use checksums
fafe521a5e3fd5bc58fcb54ee60986f7d1acf57dfc1c8e1b7bc98db7f53fb1e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.7

Release files / django_chunk_upload-2.0.0-py3-none-any.whl

Download URL django_chunk_upload-2.0.0-py3-none-any.whl
Size 11.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5861e3600f80e7df6c62bd2a894f93809792461b0c18c76e17b026e2cd1ef1e7
BLAKE2b-256 checksum
How to use checksums
2e1cc150e4f10640a4dbc0a549aeebb44bf21996cd16473d8acabfcb425e6b93
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.7

Security for django-chunk-upload 2.0.0

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.

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page