开发者

upload size on multiple file upload with django

开发者 https://www.devze.com 2023-04-09 06:56 出处:网络
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 p

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)
0

精彩评论

暂无评论...
验证码 换一张
取 消