alican / django-tus

Django app implementing server side of tus protocol to powering resumable file uploads for django projects. More Info about: http://tus.io/
MIT License
49 stars 32 forks source link

Problem with patch endpoint -> mem cache fails with wsgi. #23

Open RubenGarcia opened 3 years ago

RubenGarcia commented 3 years ago

Description

I added some code to verify parameters before forwarding the django call to django_tus: urls.py:

    url(r'^upload/$', tus.tusUpload, name='tus_upload'),
    url(r'^upload/(?P<resource_id>[0-9a-z-]+)$', tus.tusUpload, name='tus_upload_chunks'),

tus.py:

@csrf_exempt
def tusUpload(*args, **kwargs):
  # checking code
  return TusUpload.as_view()(*args, **kwargs)

This is working well for upload and post, but is failing in patch with the following error:

TypeError at /demo/upload/249c8b5d-b793-4e2d-8e7b-1718b7aadc41
int() argument must be a string, a bytes-like object or a number, not 'NoneType'

def patch(self, request, resource_id, *args, **kwargs):
     tus_file = TusFile(str(resource_id)) 

I think the resource_id is not being passed; but I could not find a tutorial on how to do this.

What I Did

Paste the command(s) you ran and the output.
If there was a crash, please include the traceback here.

b.zip

RubenGarcia commented 3 years ago

This is not the latest git; will check which version works.

RubenGarcia commented 3 years ago

I checked the code in more detail. The actual problem is the line self.file_size = int(cache.get("tus-uploads/{}/file_size".format(resource_id))) where the cache is returning None.

We are running our server in uwsgi, with 6 processes and 2 threads per process, and django cache is set to {'default': {'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'}}

The README for this project should mention that running on uwsgi needs changes to the default cache backend. I'll send a patch once I get it working.

RubenGarcia commented 3 years ago

https://github.com/alican/django-tus/pull/26 closes this.