Git Product home page Git Product logo

drf-tus's Introduction

drf-tus

image

image

A Tus (tus.io) library for Django Rest Framework

Documentation

The full documentation is at https://drf-tus.readthedocs.io.

Quickstart

Install drf-tus:

pip install drf-tus

Add it to your `INSTALLED_APPS`:

INSTALLED_APPS = (
    ...
    "rest_framework_tus",
    ...
)

Add the middleware to `MIDDLEWARE`:

MIDDLEWARE = (
    ...
    "rest_framework_tus.middleware.TusMiddleware",
    ...
)

Add URL patterns for drf-tus:

urlpatterns = [
    ...
    path(r"^", include("rest_framework_tus.urls", namespace="rest_framework_tus")),
    ...
]

Features

This library implements the following TUS API v1.0.0 protocols:

Running Tests

Does the code actually work?

source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install tox
(myenv) $ tox

Credits

Tools used in rendering this package:

drf-tus's People

Contributors

ciklop avatar dependabot[bot] avatar dirkmoors avatar jgeskens avatar mikelandzelo173 avatar rmincling avatar wadevries avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

drf-tus's Issues

Wrong offset after upload pause

Hello,

Using tus-js, I tried to upload a "big" file (like 630Mo), with a chunk size of ~100485760 bytes. During the upload, I have closed my browser.

Expected behaviour : the file is partially written into /tmp, the Upload-Offset field is set at the number of bytes actually written.

Actual behaviour : the file is partially written into /tmp, the Upload-Offset field is set at the number of chunks processed times the size of a chunk.

In my tests, I have stopped the upload during the third chunk. I have 1004857602+67813376 = 268784896 bytes written on the filesystem whereas my Upload-Length in database is 1004857603 = 301457280 bytes.

In django settings I have configured:
FILE_UPLOAD_MAX_MEMORY_SIZE = 162144000
DATA_UPLOAD_MAX_MEMORY_SIZE = None

I tried to track down the issue and it seems that the issue lies in the models.py file:

` def write_data(self, bytes, chunk_size):
write_bytes_to_file(self.temporary_file_path, self.upload_offset, bytes, makedirs=True)

    self.upload_offset += chunk_size
    self.save()

`
Here, the chunk_size assumes that the chunk is totally uploaded. In my tests, it looks like I get the correct upload_offset value using len(bytes) whereas than chunk_size for the update for upload_offset but I don't know if that could cause other issues, or if I missed something.

Is there any reason to not use len(bytes) ?

Regards,
Grégoire

Uploading Fail while uploading from android-tus-client.

  • Django version: 3.2
  • Python version: 3.10
  • Operating System: Linux

Description
I am using drf-tus in django. i am getting KeyError while uploading from android-tus-client on the on the other hand tus-js-client is working fine. I don’t understand why am getting this error because the drf-tus is working fine with tus-js-client except android-tus-client.

I have try to upload files using android-client and tus-js-client they both are working fine with tusd server, but when is try to upload file using drf-tus in django the android-client is getting keyError on get_chuck() because the android-client is sending Transfer-Encoding": "chunked" and chuck data is b"" header on the other hand the js-client is working only

I want to upload file from android and js-clients as well but android is not working for me. Please help me on it.

DRF_tus partial_update print header is while uploading from tus-js-client

    "Content-Length": "152944",
    "Content-Type": "application/offset+octet-stream",
    "Connection": "keep-alive",
    "Tus-Resumable": "1.0.0",
    "Upload-Offset": "0"

DRF_tus partial_update print header is while uploading from android-tus-client

    "Content-Length": "",
    "Content-Type": "application/offset+octet-stream",
    "Tus-Resumable": "1.0.0",
    "Upload-Offset": "0",
    "Expect": "100-continue",
    "Transfer-Encoding": "chunked"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.