Uploading file takes more than expected
Closed this issue · 0 comments
Hi there
First, thanks for this awesome plugin. Works like a charm and is (almost) exactly what I need.
So maybe I'm understanding something wrong of need to configure something but I have the following scenario:
- I have a simple upload form where the user can upload a big file (let's say up to a couple of hundred MBs)
- The upload in via django-s3file and the progress loader works like a charm
- Then the POST method is called at the end of the JS direct upload to S3
- My code receives the temporary file and on save transforms the key that then is stored in the DB
The part of my code looks like this to handle the upload:
form = UploadForm(request.POST, request.FILES)
if form.is_valid():
upload = request.FILES['upload']
obj = Obj()
obj.save()
obj.upload = upload # The upload_to needs to get the object id, so it's done in a second save call
obj.save()
So this works. But the thing is that the last step 4) apparently takes more time at obj.upload = upload
, the bigger the file is (a couple of hundred MBs took already something like 20-30s). So the user when they click "upload" see the upload progress but then have to wait still quite some time until the view actually loaded. I assume that this is because the file is "moved" on S3. But it probably is not a move but a copy, which would explain that the bigger the file is it takes longer.
So, somehow I this can't the the expected behaviour as it does upload the file directly to S3 but the advantage is only partially as the user now has to wait for the upload almost twice (upload + the time that it takes to copy the file).
Is this intended like that? Are there any good workaround or can I configure something in django-s3file or django-storages that the saving doesn't take that much time?
Thanks!