breautek commented on issue #328:
URL: 
https://github.com/apache/cordova-plugin-file-transfer/issues/328#issuecomment-2086335062

   > If Content-Length is 2147483640(<2147483648),progressEvent.total is 
right(not zero).
   
   Actually, this is probably because we use 
[getContentLength](https://docs.oracle.com/javase/8/docs/api/java/net/URLConnection.html#getContentLength--)
 when generating progress events 
[here](https://github.com/apache/cordova-plugin-file-transfer/blob/f12b73eb0ba70536072eeab89843c96082fce512/src/android/FileTransfer.java#L775).
   
   the `getContentLength` API uses an so it has a max range of 2147483640 and 
if the content length exceeds it, then `-1` is returned (and as a result is 
treated as if the request is a chunked transfer request). So that probably 
explains what you're seeing...
   
   There is a [long 
version](https://docs.oracle.com/javase/8/docs/api/java/net/URLConnection.html#getContentLengthLong--)
 of the API but returning a long to the webview is dangerous because it exceeds 
the max safe integer of the javascript engine. If the file size is between 
`Number.MAX_SAFE_INTEGER` and the `Long.MAX` then it will also introduce subtle 
issues as the numbers may incur floating point errors once it exceeds 
`Number.MAX_SAFE_INTEGER`
   
   Despite this danger, it seems like iOS is using [long 
long](https://github.com/apache/cordova-plugin-file-transfer/blob/master/src/ios/CDVFileTransfer.m#L809)
 in it's implementation.
   
   The JS `Number.MAX_SAFE_INTEGER` is `9007199254740991`, or about 8TB if I 
did my math right, so for the purpose of reporting file size, I doubt anyone is 
downloading 8TB files, so I guess using a Long would be ok.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org
For additional commands, e-mail: issues-h...@cordova.apache.org

Reply via email to