Add 'range' field to tasks to allow the operation to work only on a portion of the file #157
Replies: 10 comments 15 replies
-
This would also enable progress % if the server does not provide content length, but it is known by the developer (see #156), where the range extend is effectively the known file size. |
Beta Was this translation helpful? Give feedback.
-
(null, null) for entire file makes sense. |
Beta Was this translation helpful? Give feedback.
-
Also, how the write file is done? Sort of
And then
This way the file write is optimized by reducing the numbers of write. If chunks size is 1024*1024, there should be evident optimization for small files (150-500KB), which are much used on mobile apps. |
Beta Was this translation helpful? Give feedback.
-
As for the high level logic, Im not sure if that idea is the best one, but lets say we have a file with Result would be 3 DownloadTasks downloading in parallel 500KB each. |
Beta Was this translation helpful? Give feedback.
-
This is the class, lmk if you see per improvement
Sample code to use it.
|
Beta Was this translation helpful? Give feedback.
-
The more I think about it, I feel we should not add a range option, and let the developer set the range or content-length header if needed. To force a known content length you can then either set the range to end there, or set the content-length header. The logic in the downloader can be updated to take the range or content-length values if the server does not provide one. This keeps the API simple (no need for additional fields in Thoughts? |
Beta Was this translation helpful? Give feedback.
-
@delfme do you happen to have a URL that I can use to test this? It needs to be
I want to test if I set a Range, or a Content-Length header in the Hope you can help me out! |
Beta Was this translation helpful? Give feedback.
-
@delfme I've implemented this functionality now on the I've simulated this works in my setting, but would like to her your experience. |
Beta Was this translation helpful? Give feedback.
-
Implemented in V7.11.0 |
Beta Was this translation helpful? Give feedback.
-
Hello @781flyingdutchman something came up and I still couldnt test it. Even because I need to test it with our app restore backup function, which is not a quick check. But will try it asap an revert. How went your test? I mean, can this be used to download say 10 or 100 small files at time without crashing system? That would be our use case. Thx |
Beta Was this translation helpful? Give feedback.
-
Range would be an
(int?, int?)?
where null means start/end byte (inside the record) or the entire range if the whole record is null. the values are 0 based, so the max is one less than content length.We would JSON encode this as an optional array, eg "[null, 5000]" to indicate up to 5000.
Consider:
Beta Was this translation helpful? Give feedback.
All reactions