django-chunked-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.
This app is intented to work with `JQuery-File-Upload <https://github.com/blueimp/jQuery-File-Upload>`__ by `Sebastian Tschan <https://blueimp.net>`__ (`documentation <https://github.com/blueimp/jQuery-File-Upload/wiki>`__).
License: `MIT-Zero <https://romanrm.net/mit-zero>`__.
Demo
----
If you want to see a very simple Django demo project using this module, please take a look at `django-chunked-upload-demo <https://github.com/juliomalegria/django-chunked-upload-demo>`__.
Installation
------------
Install via pip:
::
pip install django-chunked-upload
And then add it to your Django ``INSTALLED_APPS``:
.. code:: python
INSTALLED_APPS = (
# ...
'chunked_upload',
)
Typical usage
-------------
1. An initial POST request is sent to the url linked to ``ChunkedUploadView`` (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>}
2. 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"
}
3. Repeatedly POST subsequent chunks using the ``upload_id`` to identify the upload to the url linked to ``ChunkedUploadView`` (or any subclass). Example:
::
{
"upload_id": "5230ec1f59d1485d9d7974b853802e31",
"my_file": <File>
}
4. Server will continue responding with the ``upload_id``, the current ``offset`` and the expiration date (``expires``).
5. Finally, when upload is completed, a POST request is sent to the url linked to ``ChunkedUploadCompleteView`` (or any subclass). This request must include the ``upload_id`` and the ``md5`` checksum (hex). Example:
::
{
"upload_id": "5230ec1f59d1485d9d7974b853802e31",
"md5": "fc3ff98e8c6a0d3087d515c0473f8677"
}
6. 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.
``CHUNKED_UPLOAD_EXPIRATION_DELTA``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* How long after creation the upload will expire.
* Default: ``datetime.timedelta(days=1)``
``CHUNKED_UPLOAD_PATH``
~~~~~~~~~~~~~~~~~~~~~~~
* Path where uploading files will be stored until completion.
* Default: ``'chunked_uploads/%Y/%m/%d'``
``CHUNKED_UPLOAD_TO``
~~~~~~~~~~~~~~~~~~~~~
* `upload_to` to be used in the Model's FileField.
* Default: ``CHUNKED_UPLOAD_PATH + '/{{ instance.upload_id }}.part'``
``CHUNKED_UPLOAD_STORAGE_CLASS``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Storage system (should be a class).
* Default: ``None`` (use default storage system)
``CHUNKED_UPLOAD_ENCODER``
~~~~~~~~~~~~~~~~~~~~~~~~~~
* Function used to encode response data. Receives a dict and returns a string.
* Default: ``DjangoJSONEncoder().encode``
``CHUNKED_UPLOAD_CONTENT_TYPE``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Content-Type for the response data.
* Default: ``'application/json'``
``CHUNKED_UPLOAD_MAX_BYTES``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Max amount of data (in bytes) that can be uploaded. ``None`` means no limit.
* Default: ``None``
``CHUNKED_CUSTOM_USER_MODEL``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Use a custom user model instead of Django default (Auth User).
* Default: ``None``
``CHUNKED_UPLOAD_MODEL_USER_FIELD_NULL``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Value of `null <https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.Field.null>`__ option in **user** field of `ChunkedUpload` model
* Default: ``True``
``CHUNKED_UPLOAD_MODEL_USER_FIELD_BLANK``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Value of `blank <https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.Field.blank>`__ option in **user** field of `ChunkedUpload` model
* Default: ``True``
Support
-------
If you find any bug or you want to propose a new feature, please use the `issues tracker <https://github.com/juliomalegria/django-chunked-upload/issues>`__. I'll be happy to help you! :-)
Raw data
{
"_id": null,
"home_page": "https://github.com/fredito1212/django-chunked-upload",
"name": "django4-chunked-upload",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "Julio M Alegria & Jesus A Bravo",
"author_email": "isc.alfredobravo@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/43/d9/6aba33ebc98443ef714243273233fa4c586b740a82792d61b10e896d991e/django4-chunked-upload-2.0.2.tar.gz",
"platform": null,
"description": "django-chunked-upload\r\n=====================\r\n\r\nThis simple django app enables users to upload large files to Django in multiple chunks, with the ability to resume if the upload is interrupted.\r\n\r\nThis app is intented to work with `JQuery-File-Upload <https://github.com/blueimp/jQuery-File-Upload>`__ by `Sebastian Tschan <https://blueimp.net>`__ (`documentation <https://github.com/blueimp/jQuery-File-Upload/wiki>`__).\r\n\r\nLicense: `MIT-Zero <https://romanrm.net/mit-zero>`__.\r\n\r\nDemo\r\n----\r\n\r\nIf you want to see a very simple Django demo project using this module, please take a look at `django-chunked-upload-demo <https://github.com/juliomalegria/django-chunked-upload-demo>`__.\r\n\r\nInstallation\r\n------------\r\n\r\nInstall via pip:\r\n\r\n::\r\n\r\n pip install django-chunked-upload\r\n\r\nAnd then add it to your Django ``INSTALLED_APPS``:\r\n\r\n.. code:: python\r\n\r\n INSTALLED_APPS = (\r\n # ...\r\n 'chunked_upload',\r\n )\r\n\r\nTypical usage\r\n-------------\r\n\r\n1. An initial POST request is sent to the url linked to ``ChunkedUploadView`` (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:\r\n\r\n::\r\n\r\n {\"my_file\": <File>}\r\n\r\n2. In return, server with response with the ``upload_id``, the current ``offset`` and the when will the upload expire (``expires``). Example:\r\n\r\n::\r\n\r\n {\r\n \"upload_id\": \"5230ec1f59d1485d9d7974b853802e31\",\r\n \"offset\": 10000,\r\n \"expires\": \"2013-07-18T17:56:22.186Z\"\r\n }\r\n\r\n3. Repeatedly POST subsequent chunks using the ``upload_id`` to identify the upload to the url linked to ``ChunkedUploadView`` (or any subclass). Example:\r\n\r\n::\r\n\r\n {\r\n \"upload_id\": \"5230ec1f59d1485d9d7974b853802e31\",\r\n \"my_file\": <File>\r\n }\r\n\r\n4. Server will continue responding with the ``upload_id``, the current ``offset`` and the expiration date (``expires``).\r\n\r\n5. Finally, when upload is completed, a POST request is sent to the url linked to ``ChunkedUploadCompleteView`` (or any subclass). This request must include the ``upload_id`` and the ``md5`` checksum (hex). Example:\r\n\r\n::\r\n\r\n {\r\n \"upload_id\": \"5230ec1f59d1485d9d7974b853802e31\",\r\n \"md5\": \"fc3ff98e8c6a0d3087d515c0473f8677\"\r\n }\r\n\r\n6. If everything is OK, server will response with status code 200 and the data returned in the method ``get_response_data`` (if any).\r\n\r\nPossible error responses:\r\n~~~~~~~~~~~~~~~~~~~~~~~~~\r\n\r\n* User is not authenticated. Server responds 403 (Forbidden).\r\n* Upload has expired. Server responds 410 (Gone).\r\n* ``upload_id`` does not match any upload. Server responds 404 (Not found).\r\n* No chunk file is found in the indicated key. Server responds 400 (Bad request).\r\n* Request does not contain ``Content-Range`` header. Server responds 400 (Bad request).\r\n* Size of file exceeds limit (if specified). Server responds 400 (Bad request).\r\n* Offsets does not match. Server responds 400 (Bad request).\r\n* ``md5`` checksums does not match. Server responds 400 (Bad request).\r\n\r\nSettings\r\n--------\r\n\r\nAdd any of these variables into your project settings to override them.\r\n\r\n``CHUNKED_UPLOAD_EXPIRATION_DELTA``\r\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n\r\n* How long after creation the upload will expire.\r\n* Default: ``datetime.timedelta(days=1)``\r\n\r\n``CHUNKED_UPLOAD_PATH``\r\n~~~~~~~~~~~~~~~~~~~~~~~\r\n\r\n* Path where uploading files will be stored until completion.\r\n* Default: ``'chunked_uploads/%Y/%m/%d'``\r\n\r\n``CHUNKED_UPLOAD_TO``\r\n~~~~~~~~~~~~~~~~~~~~~\r\n\r\n* `upload_to` to be used in the Model's FileField.\r\n* Default: ``CHUNKED_UPLOAD_PATH + '/{{ instance.upload_id }}.part'``\r\n\r\n``CHUNKED_UPLOAD_STORAGE_CLASS``\r\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n\r\n* Storage system (should be a class).\r\n* Default: ``None`` (use default storage system)\r\n\r\n``CHUNKED_UPLOAD_ENCODER``\r\n~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n\r\n* Function used to encode response data. Receives a dict and returns a string.\r\n* Default: ``DjangoJSONEncoder().encode``\r\n\r\n``CHUNKED_UPLOAD_CONTENT_TYPE``\r\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n\r\n* Content-Type for the response data.\r\n* Default: ``'application/json'``\r\n\r\n``CHUNKED_UPLOAD_MAX_BYTES``\r\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n\r\n* Max amount of data (in bytes) that can be uploaded. ``None`` means no limit.\r\n* Default: ``None``\r\n\r\n``CHUNKED_CUSTOM_USER_MODEL``\r\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n\r\n* Use a custom user model instead of Django default (Auth User).\r\n* Default: ``None``\r\n\r\n``CHUNKED_UPLOAD_MODEL_USER_FIELD_NULL``\r\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n\r\n* Value of `null <https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.Field.null>`__ option in **user** field of `ChunkedUpload` model\r\n* Default: ``True``\r\n\r\n``CHUNKED_UPLOAD_MODEL_USER_FIELD_BLANK``\r\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n\r\n* Value of `blank <https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.Field.blank>`__ option in **user** field of `ChunkedUpload` model\r\n* Default: ``True``\r\n\r\nSupport\r\n-------\r\n\r\nIf you find any bug or you want to propose a new feature, please use the `issues tracker <https://github.com/juliomalegria/django-chunked-upload/issues>`__. I'll be happy to help you! :-)\r\n",
"bugtrack_url": null,
"license": "MIT-Zero",
"summary": "Upload large files to Django in multiple chunks, with the ability to resume if the upload is interrupted. Updated to support newer versions on Django. Based on the project of Julio M Alegria.",
"version": "2.0.2",
"project_urls": {
"Download": "https://github.com/fredito1212/django-chunked-upload/tarball/2.0.2",
"Homepage": "https://github.com/fredito1212/django-chunked-upload"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "43d96aba33ebc98443ef714243273233fa4c586b740a82792d61b10e896d991e",
"md5": "b8ace575ed4d03f064e7f7dd13a4b4dd",
"sha256": "a1eaeb0c0ce35b1510638bc9024c06f9a9b17f4401a2ac0e3201f4d33f59faea"
},
"downloads": -1,
"filename": "django4-chunked-upload-2.0.2.tar.gz",
"has_sig": false,
"md5_digest": "b8ace575ed4d03f064e7f7dd13a4b4dd",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 12398,
"upload_time": "2023-05-15T06:47:24",
"upload_time_iso_8601": "2023-05-15T06:47:24.012610Z",
"url": "https://files.pythonhosted.org/packages/43/d9/6aba33ebc98443ef714243273233fa4c586b740a82792d61b10e896d991e/django4-chunked-upload-2.0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-05-15 06:47:24",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "fredito1212",
"github_project": "django-chunked-upload",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "django4-chunked-upload"
}