質問

What's really confusing is when I capture the image with the phone camera, I use FileTransfer.moveTo and it sends the image to a specified folder on my SD card as desired. I also keep a list of image objects in localStorage that looks something like this:

[
Object
ean: "42208556"
image: "file:///storage/sdcard0/PhotoscanPhotos/d51b5b77-aab1-9947-096d-b0a92dfb87eafoto.jpg"
timestamp: 1396441761000
__proto__: Object
etc etc

As part of my app, i use the same image[i].image as src attribute to dynamically add images to a list and it works fine. However, using the same parameter for FileTransfer.upload gives me the above error.

My function is a near replica of the API docs (Cordova 3.1). Code is as follows:

function uploadImagesAsJpegs(imageObject) {
    var options = new FileUploadOptions();
    options.fileKey = "file";
    options.fileName=imageObject.image.substr(imageObject.image.lastIndexOf('/')+1);
    //alert(options.fileName);//debugging ............we're happy with this
    options.mimeType="image/jpeg";
    options.chunkedMode = true;

    var serverUrl = http://172.17.7.112/mylocalserver;


    var params = {};
    params.value1 = ean;
    params.value2 = imageObject.timestamp;

    options.params = params;

    var fileTransfer = new FileTransfer();

    //alert(encodeURI(serverURL));//debugging  ............we're happy with this
    //alert("image to upload is: " + imageObject.image);//debugging............we're happy with this
    fileTransfer.upload(imageObject.image, encodeURI(serverURL), onUploadSuccess, onUploadFail, options);
}
役に立ちましたか?

解決 3

Serverside script was wrong... naturally I should have figured that out given the obvious FileTransferError.FILE_NOT_FOUND_ERR error message. Apologies for wasting everyone's time and thank you for making the effort.

他のヒント

I believe setting options.chunkedMode = false; is solving most issues during file upload, maybe give it a try.

What I would try is: 1. use exclusive mode for upload (true at the end)

fileTransfer.upload(imageObject.image, encodeURI(serverURL), onUploadSuccess, onUploadFail, Options, true);

  1. Try to move data first to the local store of device instead of working with SD Card storage. Perhaps it is a Case of permission and you just are able to upload from phone local storage.

  2. Make sure the Image is not pending in another Image as imagesource and you have full Access to the data. Perhaps read&write is needed exclusive.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top