1 Reply Latest reply on Sep 19, 2016 6:42 PM by faustot4544220

    FileTransfer fails when upload video

    faustot4544220 Level 1

      FileTransfer works for images but fails with video. It got the error code 1 FileTransferError.FILE_NOT_FOUND_ERR .

       

      Upload images

            var options = new FileUploadOptions();
            options.fileKey = "file";
            options.fileName = imageURI.substr(imageURI.lastIndexOf('/')+1);
            options.mimeType = "image/jpeg";
            options.chunkedMode=true;
            var params = new Object();
            //params.value1 = "test";
            //params.value2 = "param";
            params.upload_preset = "yyy";
            params.api_key = "xxx";
            options.params = params;
            options.chunkedMode = false;
      
              var ft = new FileTransfer();
              ft.upload(imageURI,
                encodeURI("https://api.cloudinary.com/v1_1/my_bucket/image/upload"),
                function(data){
                  cordovaHTTP.post(app.backend.postPhoto, {data: data["response"]}, {}, function(response) {
                  },
                  function(response) { alert(response.error) })
                },
                function(data){/*error*/},
                options,
                true);
      

       

      Upload videos

            var options = new FileUploadOptions();
            options.fileKey = "file";
            options.chunkedMode=true;
            options.fileName = mediaFile[0].name
            options.mimeType = ('video/'+ options.fileName.split('.').pop())
            var params = new Object();
            params.upload_preset = "yyy";
            params.api_key = "xxx";
            options.params = params;
      
              var ft = new FileTransfer();
              ft.upload(mediaFile[0].fullPath,
              encodeURI("https://api.cloudinary.com/v1_1/my_bucket/image/upload"),
              function(data){
                alert('pa')
                cordovaHTTP.post(app.backend.postVideo, {data: data["response"]}, {}, function(response) {
                },
                function(response) {alert('pum');alert(response.error) })
              },
              function(error){
                alert("An error has occurred: Code = " + error.code);
                alert("upload error source " + error.source);
                alert("upload error target " + error.target);
              },
              options);
      

       

      So how can I fix it? (I'm testing with small video 2MB but it can store larger videos)