Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Duplicate
-
3.3.0
-
None
-
None
-
Tested on Android 4.4 & 4.1 with File Transfer plugin v1.0.0
Description
Uploading a file to a remote server using the file transfer plugin it fails on every other attempt. The first attempt succeeds, second fails, third succeeds and so on. It reliably fails on every other attempt.
The file transfer works fine on Blackberry 10 and iOS builds using the same code.
Logcat output:
E/FileTransfer(22258): {"target":"https:\/\/api.pamfax.biz\/FaxJob\/AddFile?filename=GetFile-12.pdf&apioutputformat=API_FORMAT_JSON&apicheck=f4aed3c821ffbf340d62040528c08db5&apikey=BostonDell-Vandenberg&usertoken=bd6paoben9j079lv8feebkctf1uhalvs","source":"cdvfile:\/\/localhost\/persistent\/Download\/GetFile-12.pdf","http_status":0,"code":3} E/FileTransfer(22258): java.io.EOFException E/FileTransfer(22258): at com.squareup.okhttp.internal.Util.readAsciiLine(Util.java:314) E/FileTransfer(22258): at com.squareup.okhttp.internal.http.RawHeaders.fromBytes(RawHeaders.java:301) E/FileTransfer(22258): at com.squareup.okhttp.internal.http.HttpTransport.readResponseHeaders(HttpTransport.java:130) E/FileTransfer(22258): at com.squareup.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:630) E/FileTransfer(22258): at com.squareup.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:385) E/FileTransfer(22258): at com.squareup.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:334) E/FileTransfer(22258): at com.squareup.okhttp.internal.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:534) E/FileTransfer(22258): at com.squareup.okhttp.internal.http.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:148) E/FileTransfer(22258): at org.apache.cordova.filetransfer.FileTransfer$1.run(FileTransfer.java:441) E/FileTransfer(22258): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) E/FileTransfer(22258): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) E/FileTransfer(22258): at java.lang.Thread.run(Thread.java:841) E/FileTransfer(22258): Failed after uploading 256232 of 256232 bytes.
Here is the code I am using:
var uploadFile = function (fileUri, mimeType) { var options = new FileUploadOptions(), filename = fileUri.substr(fileUri.lastIndexOf('/') + 1).split('?')[0], url = Api.getUrl('FaxJob/AddFile', { filename: filename }), ft = new FileTransfer(); options.fileKey = 'file'; options.fileName = filename; options.params = { filename: filename }; ft.upload( fileUri, encodeURI(url), function(entry) { $timeout(function () { $scope.$apply(function () { $log.debug('file uploaded: ', entry); Loading.hide(); $scope.fax.uploadingFiles = false; $scope.getFiles(); }); }); }, function(error) { $timeout(function () { $scope.$apply(function () { Loading.hide(); $scope.fax.uploadingFiles = false; $rootScope.message = { type: 'danger', content: 'ERR_FILE_WRONG_CHECKSUM' }; $log.error('File transfer error code: ' + error.code); $log.error('File transfer error source: ' + error.source); $log.error('File transfer error target: ' + error.target); }); }); }, options );
Javascript console error output:
File transfer error code: 3 File transfer error source: cdvfile://localhost/persistent/Download/GetFile-12.pdf File transfer error target: https://api.pamfax.biz/FaxJob/AddFile?filename=GetFile-12.pdf&apioutputform…b5&apikey=BostonDell-Vandenberg&usertoken=bd6paoben9j079lv8feebkctf1uhalvs
Attachments
Issue Links
- duplicates
-
CB-2293 File Transfer of picture fails on every other picture
- Closed