0

here's my javascript phonegap code, and, when i try tu upload a little file with the chunckedMode = true, the ft.upload redirect on the error handler. I don't really understand what's the problem source.

function uploadFile() {

  function uploadSuccess(success)
  {
    alert('good');
    //alert(JSON.stringify(success.response));
  }

  function uploadError(error)
  {
    alert('error');
    alert(error.response);
  }

  var options = new FileUploadOptions();
  options.fileKey="document";
  options.fileName=file.substr(file.lastIndexOf('/')+1);
  options.mimeType="application/octet-stream";

  var params = new Object();
  params.value1 = "test";
  params.value2 = "param";

  options.params = params;
  options.chunkedMode = true;

  var ft = new FileTransfer();

  ft.upload(file, "http://myserver/file.php", uploadSuccess, uploadError, options);
  alert('after up');
}
Yeppao
  • 130
  • 2
  • 12
  • Your JS in the post looks totally wrong - is this what you actually have in your app? The success and error functions are inside the upload function. Where are you getting the "file" from? There is no parameter being passed in to your uploadFile method. – codemonkey Mar 16 '12 at 15:43
  • The file is in the file var, who is set in another function. In my app, i have no problem to send an image when the chunkedMode is set at false (it calls the function uploadSuccess inside the upload function with no problem, no error), but when i set it at a true state (like in the code), it take the uploadError function... – Yeppao Mar 16 '12 at 15:58
  • Is there any chance it's a problem with your server code? I've been using the file upload with chunkedMode left as the default (which is true) and never had any problems. – codemonkey Mar 16 '12 at 16:32
  • How can i turn on the chunkedMode in my server (or in my virtual host? (I'm using Nginx..) – Yeppao Mar 17 '12 at 00:38
  • Can't help you there I'm afraid. I used Apache and didn't have to do anything to enable support for it. – codemonkey Mar 17 '12 at 15:13
  • I can't edit that comment so I'll add this one - You will have to look for how to enable streaming uploads for Nginx. – codemonkey Mar 17 '12 at 15:25

1 Answers1

1

I finally solved my problem :

Step one :

Download NGINX Chunkin Module : https://github.com/agentzh/chunkin-nginx-module

Step two :

reconfigure nginx with --add-module=/path/to/the/module

Re-install it..

Step three :

Go to the vhost configuration file add this (code into the braces) :

server {
        chunkin on;

        error_page 411 = @my_411_error;
        location @my_411_error {
            chunkin_resume;
        }

        ...
      }

Now your nginx server accept the chunked mode file transfer.

Yeppao
  • 130
  • 2
  • 12