You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Boston Dell-Vandenberg (JIRA)" <ji...@apache.org> on 2014/02/13 23:32:21 UTC

[jira] [Commented] (CB-6034) File transfer fails every other attempt on Android

    [ https://issues.apache.org/jira/browse/CB-6034?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13900814#comment-13900814 ] 

Boston Dell-Vandenberg commented on CB-6034:
--------------------------------------------

Unfortunately I'm getting a version not found installing cordova@3.4.0-rc.1, does it exist on npm yet?

> File transfer fails every other attempt on Android
> --------------------------------------------------
>
>                 Key: CB-6034
>                 URL: https://issues.apache.org/jira/browse/CB-6034
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Plugin File Transfer
>    Affects Versions: 3.3.0
>         Environment: Tested on Android 4.4 & 4.1 with File Transfer plugin v1.0.0
>            Reporter: Boston Dell-Vandenberg
>
> 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:
> {code}
> 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.
> {code}
> Here is the code I am using:
> {code}
> 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
>     );
> {code}
> Javascript console error output:
> {code}
> 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 
> {code}



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)