From f4dcf992cbc5480154f54722b91ed898247b3f8c Mon Sep 17 00:00:00 2001 From: Shane Zheng Date: Thu, 17 Dec 2015 14:35:21 +1300 Subject: [PATCH 1/2] Add _currentChunkSize field and update the meaning of _chunkSize field _currentChunkSize is the new field, which means the size of the current chunk. _chunkSize has its meaning change to the configured chunk size. --- src/upload.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/upload.js b/src/upload.js index d21bf184..9f1a1a5c 100644 --- a/src/upload.js +++ b/src/upload.js @@ -219,7 +219,8 @@ ngFileUpload.service('UploadBase', ['$http', '$q', '$timeout', function ($http, slice.name = file.name; slice.ngfName = file.ngfName; if (config._chunkSize) { - formData.append('_chunkSize', config._end - config._start); + formData.append('_chunkSize', config._chunkSize); + formData.append('_currentChunkSize', config._end - config._start); formData.append('_chunkNumber', Math.floor(config._start / config._chunkSize)); formData.append('_totalSize', config._file.size); } From cab2f321dc77db80dc78ec93e104e6799a852e69 Mon Sep 17 00:00:00 2001 From: Shane Zheng Date: Thu, 17 Dec 2015 14:44:09 +1300 Subject: [PATCH 2/2] Update the readme file about the chunkSize and currentChunkSize fields. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 368f8d60..3e996a4a 100644 --- a/README.md +++ b/README.md @@ -406,8 +406,8 @@ On your server you need to keep track of what files are being uploaded and how m set that back to zero to allow re-uploading the same file. * Optionally you can specify `resumeChunkSize` to upload the file in chunks to the server. This will allow uploading to GAE or other servers that have file size limitation and trying to upload the whole request before passing it for internal processing.
- If this option is set the requests will have three extra fields: - `_chunckSize`, `_chunkNumber` (zero starting), and `_totalSize` to help the server to write the uploaded chunk to + If this option is set the requests will have the following extra fields: + `_chunkSize`, `_currentChunkSize`, `_chunkNumber` (zero starting), and `_totalSize` to help the server to write the uploaded chunk to the correct position. Uploading in chunks could slow down the overall upload time specially if the chunk size is too small.