Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-13591

File sending fails on first try and succeds on retry.

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Blocker
    • Resolution: Won't Fix
    • Affects Version/s: Master
    • Fix Version/s: None
    • Labels:
    • Environment:
    • Flags:
      Important

      Description

                      var ef = JSON.parse(localStorage.getItem(lsKey));
      
                      var win = function (json) {
                          var response = JSON.parse(json.response);
                          localStorage.removeItem("EF"+response.data.lsKey);
                          actualizarHeader();
                          return;
                      }
                      var fail = function (error) {
                          var err = error;
                          n_enviarEF--;
                      }
      
                      var options = new FileUploadOptions();
                      options.fileKey = "file";
                      options.fileName = ef.f.substr(ef.f.lastIndexOf('/') + 1);
                      options.mimeType = "image/jpeg";
                      options.params = ef; // if we need to send parameters to the server request
                      var ft = new FileTransfer();
                      ft.upload(ef.f, encodeURI(surl), win, fail, options);
      

      The first time this code is run, it will fail. On retry, it runs perfectly.

      Messages from the monitor app.

      First Time it is run:
      
      11-19 12:15:54.500: D/FileTransfer(17031): upload file:///mnt/sdcard/Android/data/com.alarmar.gps/cache/1511111749734.jpg to https://xxxxxxxxxxxxxxxxxxxx.com.co/ws/gl/gl.php
      11-19 12:15:54.500: D/FileTransfer(17031): fileKey: file
      11-19 12:15:54.500: D/FileTransfer(17031): fileName: 1511111749734.jpg
      11-19 12:15:54.500: D/FileTransfer(17031): mimeType: image/jpeg
      11-19 12:15:54.500: D/FileTransfer(17031): params: {"f":"file:\/\/\/mnt\/sdcard\/Android\/data\/com.alarmar.gps\/cache\/1511111749734.jpg","u":"15347039","m":"setEF","ts":1511111750107,"a":"22396"}
      11-19 12:15:54.500: D/FileTransfer(17031): trustEveryone: false
      11-19 12:15:54.500: D/FileTransfer(17031): chunkedMode: true
      11-19 12:15:54.500: D/FileTransfer(17031): headers: null
      11-19 12:15:54.500: D/FileTransfer(17031): objectId: 2
      11-19 12:15:54.500: D/FileTransfer(17031): httpMethod: POST
      11-19 12:15:54.510: D/FileTransfer(17031): Content Length: 61589
      11-19 12:15:54.540: D/FileTransfer(17031): Sent 61589 of 61589
      11-19 12:15:54.550: W/FileTransfer(17031): Error getting HTTP status code from connection.
      11-19 12:15:54.550: W/FileTransfer(17031): java.io.EOFException
      11-19 12:15:54.550: W/FileTransfer(17031): 	at libcore.io.Streams.readAsciiLine(Streams.java:203)
      11-19 12:15:54.550: W/FileTransfer(17031): 	at libcore.net.http.HttpEngine.readResponseHeaders(HttpEngine.java:573)
      11-19 12:15:54.550: W/FileTransfer(17031): 	at libcore.net.http.HttpEngine.readResponse(HttpEngine.java:821)
      11-19 12:15:54.550: W/FileTransfer(17031): 	at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:283)
      11-19 12:15:54.550: W/FileTransfer(17031): 	at libcore.net.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:495)
      11-19 12:15:54.550: W/FileTransfer(17031): 	at libcore.net.http.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:134)
      11-19 12:15:54.550: W/FileTransfer(17031): 	at org.apache.cordova.filetransfer.FileTransfer$1.run(FileTransfer.java:504)
      11-19 12:15:54.550: W/FileTransfer(17031): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
      11-19 12:15:54.550: W/FileTransfer(17031): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
      11-19 12:15:54.550: W/FileTransfer(17031): 	at java.lang.Thread.run(Thread.java:856)
      11-19 12:15:54.550: E/FileTransfer(17031): {"target":"https:\/\/xxxxxxxxxxxxxxxxxxxxxxxxxxx.com.co\/ws\/gl\/gl.php","http_status":0,"code":3,"source":"file:\/\/\/mnt\/sdcard\/Android\/data\/com.alarmar.gps\/cache\/1511111749734.jpg","exception":"java.io.EOFException"}
      11-19 12:15:54.550: E/FileTransfer(17031): java.io.EOFException
      11-19 12:15:54.550: E/FileTransfer(17031): 	at libcore.io.Streams.readAsciiLine(Streams.java:203)
      11-19 12:15:54.550: E/FileTransfer(17031): 	at libcore.net.http.HttpEngine.readResponseHeaders(HttpEngine.java:573)
      11-19 12:15:54.550: E/FileTransfer(17031): 	at libcore.net.http.HttpEngine.readResponse(HttpEngine.java:821)
      11-19 12:15:54.550: E/FileTransfer(17031): 	at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:283)
      11-19 12:15:54.550: E/FileTransfer(17031): 	at libcore.net.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:495)
      11-19 12:15:54.550: E/FileTransfer(17031): 	at libcore.net.http.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:134)
      11-19 12:15:54.550: E/FileTransfer(17031): 	at org.apache.cordova.filetransfer.FileTransfer$1.run(FileTransfer.java:504)
      11-19 12:15:54.550: E/FileTransfer(17031): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
      11-19 12:15:54.550: E/FileTransfer(17031): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
      11-19 12:15:54.550: E/FileTransfer(17031): 	at java.lang.Thread.run(Thread.java:856)
      11-19 12:15:54.550: E/FileTransfer(17031): Failed after uploading 61589 of 61589 bytes.
      
      On retry:
      
      11-19 12:16:04.550: D/FileTransfer(17031): upload file:///mnt/sdcard/Android/data/com.alarmar.gps/cache/1511111749734.jpg to https://xxxxxxxxxxxxxxxxxxxx.com.co/ws/gl/gl.php
      11-19 12:16:04.550: D/FileTransfer(17031): fileKey: file
      11-19 12:16:04.550: D/FileTransfer(17031): fileName: 1511111749734.jpg
      11-19 12:16:04.550: D/FileTransfer(17031): mimeType: image/jpeg
      11-19 12:16:04.550: D/FileTransfer(17031): params: {"f":"file:\/\/\/mnt\/sdcard\/Android\/data\/com.alarmar.gps\/cache\/1511111749734.jpg","u":"15347039","m":"setEF","ts":1511111750107,"a":"22396"}
      11-19 12:16:04.550: D/FileTransfer(17031): trustEveryone: false
      11-19 12:16:04.550: D/FileTransfer(17031): chunkedMode: true
      11-19 12:16:04.550: D/FileTransfer(17031): headers: null
      11-19 12:16:04.550: D/FileTransfer(17031): objectId: 3
      11-19 12:16:04.550: D/FileTransfer(17031): httpMethod: POST
      11-19 12:16:04.560: D/FileTransfer(17031): Content Length: 61589
      11-19 12:16:04.750: D/FileTransfer(17031): Sent 61589 of 61589
      11-19 12:16:05.640: D/FileTransfer(17031): response code: 200
      11-19 12:16:05.640: D/FileTransfer(17031): response headers: {null=[HTTP/1.1 200 OK], access-control-allow-credentials=[true], access-control-allow-headers=[Content-Type, *], access-control-allow-methods=[GET, POST, OPTIONS], access-control-allow-origin=[*], Connection=[Keep-Alive], Content-Length=[72], Content-Type=[application/json], Date=[Sun, 19 Nov 2017 17:16:06 GMT], Keep-Alive=[timeout=5, max=100], Server=[Apache/2.4.18 (Ubuntu)], X-Android-Received-Millis=[1511111765654], X-Android-Sent-Millis=[1511111764742]}
      11-19 12:16:05.650: D/FileTransfer(17031): got response from server
      11-19 12:16:05.650: D/FileTransfer(17031): {"success":true,"data":{"success":true,"tk":-1,"lsKey":"1511111750107"}}
      11-19 12:16:05.650: D/SystemWebChromeClient(17031): file:///android_asset/www/js/index.js: Line 439 : win: {"response":"{\"success\":true,\"data\":{\"success\":true,\"tk\":-1,\"lsKey\":\"1511111750107\"}}","responseCode":200,"objectId":"","bytesSent":61576}
      11-19 12:16:05.660: I/Web Console(17031): win: {"response":"{\"success\":true,\"data\":{\"success\":true,\"tk\":-1,\"lsKey\":\"1511111750107\"}}","responseCode":200,"objectId":"","bytesSent":61576} at file:///android_asset/www/js/index.js:439
      
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              moricio Mauricio Ramirez
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: