upload size on multiple file upload with django
I'm using Django to upload some files with one multiple file input. Using this upload-handler that writes the cumulated size of uploaded chunks in a session-variable and some jQuery I finally got a progress-bar working. But I still got a problem with the uploaded file size, i.e. the files are uploaded to astonishing 144% of their original size. At least that's what the progress bar says. The size of the uploaded files on the server directory actually is as it should be.
As you see in the handler-script, the size is cumulated via:
data['uploaded'] += self.chunk_size
My guess is that self.chunk_size
is a static value and not the actual size of the received chunks. So when there is a chunk received with a smaller size - in case I upload files that are smaller t开发者_如何学JAVAhan the chunk-limit set - there is more cumulated than actually uploaded.
Now my question: Is there a way to get the actual chunk size?
I think you can use the length of the raw_data
instead:
data['uploaded'] += len(raw_data)
精彩评论