2013-08-29 83 views
3

我已升級到最新版本的Phonegap 3.0.0。這似乎引入了間歇性上傳錯誤問題。Phonegap/Cordova FileTransfer - Error 3 - Android

我有一個簡單的上傳照片的應用程序。 我選擇了一張照片,然後按上傳。

隨機它將返回「錯誤代碼3」。這是來自我所瞭解的連接問題。 在代碼中,我輸出上載的進度。錯誤隨機出現在上傳的不同階段。

代碼的基本精簡版是

function getPhoto(source) { 
    navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50, 
     destinationType: destinationType.FILE_URI, 
     sourceType: source }); 
} 

function onPhotoDataSuccess(img) { 
    imgUrl = img; 
    $('#smallImage').attr('src',imgUrl); 
} 

function doUpload() { 

    ft.onprogress = function(progressEvent) { 
     if (progressEvent.lengthComputable) { 
       var perc = Math.floor(progressEvent.loaded/progressEvent.total * 100); 
       $("#status").text("Uploading: " + perc + "%"); 
     } else { 
       if($("#status").text() == "") { 
        $("#status").text("Uploading"); 
       } else { 
        $("#status").text($("#status").text() + "."); 
       } 
     } 
    }; 

    var options = new FileUploadOptions(); 
    options.fileKey="image"; 
    options.fileName=imgUrl.substr(imgUrl.lastIndexOf('/')+1); 
    options.mimeType="image/jpeg"; 
    options.chunkedMode = false; 

    ft.upload(imgUrl, baseURL + "?do_upload", uploadSuccess, uploadFail, options, true); 
} 

我已經覆蓋了更多其他人的建議,儘管我不認爲它相關的因間歇性

  • 加真到上傳命令的末尾以啓用自簽名SSL。無論如何,我並沒有使用SSL。
  • 變更在config.xml
  • 禁用分塊模式

有誰知道這可能是什麼其他的訪問來歷?

更新:

我設法得到它給了我一個VD下可能發生的錯誤日誌

08-29 15:06:55.172: D/FileTransfer(531): upload content://media/external/images/media/14 to http://exampledomain.com?page=do_upload 
08-29 15:06:55.172: D/FileTransfer(531): fileKey: image 
08-29 15:06:55.172: D/FileTransfer(531): fileName: 14 
08-29 15:06:55.172: D/FileTransfer(531): mimeType: image/jpeg 
08-29 15:06:55.172: D/FileTransfer(531): params: {} 
08-29 15:06:55.172: D/FileTransfer(531): trustEveryone: true 
08-29 15:06:55.172: D/FileTransfer(531): chunkedMode: false 
08-29 15:06:55.172: D/FileTransfer(531): headers: null 
08-29 15:06:55.172: D/FileTransfer(531): objectId: 1 
08-29 15:06:55.172: D/FileTransfer(531): httpMethod: POST 
08-29 15:06:55.192: D/FileTransfer(531): Content Length: 15007 
08-29 15:06:55.202: D/FileTransfer(531): Sent 15007 of 15007 
08-29 15:06:55.202: W/PluginManager(531): THREAD WARNING: exec() call to FileTransfer.upload blocked the main thread for 54ms. Plugin should use CordovaInterface.getThreadPool(). 
08-29 15:06:55.212: W/FileTransfer(531): Error getting HTTP status code from connection. 
08-29 15:06:55.212: W/FileTransfer(531): java.io.EOFException 
08-29 15:06:55.212: W/FileTransfer(531): at com.squareup.okhttp.internal.Util.readAsciiLine(Util.java:314) 
08-29 15:06:55.212: W/FileTransfer(531): at com.squareup.okhttp.internal.http.RawHeaders.fromBytes(RawHeaders.java:301) 
08-29 15:06:55.212: W/FileTransfer(531): at com.squareup.okhttp.internal.http.HttpTransport.readResponseHeaders(HttpTransport.java:130) 
08-29 15:06:55.212: W/FileTransfer(531): at com.squareup.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:630) 
08-29 15:06:55.212: W/FileTransfer(531): at com.squareup.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:385) 
08-29 15:06:55.212: W/FileTransfer(531): at com.squareup.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:334) 
08-29 15:06:55.212: W/FileTransfer(531): at com.squareup.okhttp.internal.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:534) 
08-29 15:06:55.212: W/FileTransfer(531): at org.apache.cordova.filetransfer.FileTransfer$3.run(FileTransfer.java:444) 
08-29 15:06:55.212: W/FileTransfer(531): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076) 
08-29 15:06:55.212: W/FileTransfer(531): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569) 
08-29 15:06:55.212: W/FileTransfer(531): at java.lang.Thread.run(Thread.java:856) 
08-29 15:06:55.223: E/FileTransfer(531): {"target":"http:\/\/exampledomain.com\/?page=do_upload","source":"content:\/\/media\/external\/images\/media\/14","http_status":0,"code":3} 
08-29 15:06:55.223: E/FileTransfer(531): java.io.EOFException 
08-29 15:06:55.223: E/FileTransfer(531): at com.squareup.okhttp.internal.Util.readAsciiLine(Util.java:314) 
08-29 15:06:55.223: E/FileTransfer(531): at com.squareup.okhttp.internal.http.RawHeaders.fromBytes(RawHeaders.java:301) 
08-29 15:06:55.223: E/FileTransfer(531): at com.squareup.okhttp.internal.http.HttpTransport.readResponseHeaders(HttpTransport.java:130) 
08-29 15:06:55.223: E/FileTransfer(531): at com.squareup.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:630) 
08-29 15:06:55.223: E/FileTransfer(531): at com.squareup.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:385) 
08-29 15:06:55.223: E/FileTransfer(531): at com.squareup.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:334) 
08-29 15:06:55.223: E/FileTransfer(531): at com.squareup.okhttp.internal.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:534) 
08-29 15:06:55.223: E/FileTransfer(531): at org.apache.cordova.filetransfer.FileTransfer$3.run(FileTransfer.java:444) 
08-29 15:06:55.223: E/FileTransfer(531): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076) 
08-29 15:06:55.223: E/FileTransfer(531): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569) 
08-29 15:06:55.223: E/FileTransfer(531): at java.lang.Thread.run(Thread.java:856) 
08-29 15:06:55.223: E/FileTransfer(531): Failed after uploading 15007 of 15007 bytes. 

更新 我發現這似乎是在爲同樣的問題科爾多瓦錯誤跟蹤器沒有解決方案。 https://issues.apache.org/jira/browse/CB-2293#comment-13753360

+0

我們與版本2.6.0有相同的錯誤。 – kzfabi

回答