Gustavo
Gustavo

Reputation: 13

Cordova / PhoneGap Upload Error on Windows Phone 8.0

Cordova / PhoneGap Upload Error on Windows Phone 8.0

Introduction

Hello everyone, I'm working with cordova 3.6.3 and Windows Phone 8.0
I have a piece of code that works on Android 4. That code is for uploading an image to the server, using cordova-plugin-file-transfer (version 0.5.0)

Code

var options = new FileUploadOptions();

options.fileKey = "newCommentMailForm";
options.fileName = attachedImage.FileName;
options.chunkedMode = true;

var params = {};
params.imageUid = attachedImage.ImageUid;

options.params = params;

var fileTransfer = new FileTransfer();

fileTransfer.upload(
  attachedImage.ImageURI,
  encodeURI(WEBAPI_SERVER + "/api/upload"),
  function (fileUploadResult) {
    app.onSendImageSuccess(fileUploadResult, attachedImage);
  },
  app.onSendImageFail,
  options,
  true); 

onSendImageSuccess: function (fileUploadResult, attachedImage) {
// success
},

onSendImageFail: function (fileTransferError) {
    Log("Code = " + fileTransferError.code);
    Log("Source " + fileTransferError.source);
    Log("Target " + fileTransferError.target);
},

Error

In Windows Phone 8.0 I'm getting the error FileTransferError.FILE_NOT_FOUND_ERR (Code = 1) after upload method was called.

The path to the selected file for upload comes from navigator.camera.getPicture() method and is "x-wmapp0:/././//CaptureImagesCache/WP_20150213_003.jpg"

Question

What is the correct path for accesing the image I want to upload? That path should be the "fileURL" parameter of upload method (cordova-plugin-file-transfer)

Thanks!
Gustavo

Upvotes: 0

Views: 315

Answers (1)

Gustavo
Gustavo

Reputation: 13

The trick is to replace "x-wmapp0:/./." with an empty string.

Upvotes: 0

Related Questions