Save image from phone into app's appery.io database. Using Camera_getPicture and FILE_URI.

Hi,
I'm trying to upload images from my phone into my app's appery.io database. I'm trying to use the camera_getpicture service with destinationType set to FILE_URI and sourceType set to PHOTOLIBRARY.

I found these two threads below, but I can't make the upload work:
https://getsatisfaction.com/apperyio/...
and
https://getsatisfaction.com/apperyio/...

Basically,
1.- I am using the UploadApp sample app, added the camera_getpicture service
2.- The camera_getpicture service runs, I select a file, and upon success, it starts...
3.- A a JS and corresponding service (that calls the JS) with the following code (as suggested in the links above):

var file = File(data.imageURI);
uploadPhoto(data.imageURI);

function uploadPhoto(imageURI) {
var options = new FileUploadOptions();
options.fileKey="file";
options.fileName=imageURI.substr(imageURI.lastIndexOf('/')+1);
options.mimeType="image/jpeg";

var params = {

headers: { 'X-Appery-Database-Id': "5c36c98e2e22d7776d0fc6ae",
'X-Appery-Session-Token': localStorage.getItem('stoken')

}
};

options.params = params;

var ft = new FileTransfer();
ft.upload(imageURI, encodeURI("https://api.appery.io/rest/1/db/files"), win, fail, options);
}

function win(r) {
alert("success");
console.log("Code = " + r.responseCode);
console.log("Response = " + r.response);
console.log("Sent = " + r.bytesSent);
}

function fail(error) {
alert("An error has occurred: Code = " + error.code);
console.log("upload error source " + error.source);
console.log("upload error target " + error.target);
}

return [{
type: 'service',
name: 'Gallery_Upload',
deps: ['Apperyio', uploadPhoto]
}];
----------
The services are giving me a "success" alert even though they are not uploading the image.

Can you please provide instructions on how I should go about implementing this?

Thanks.
2 people have
this question
+1
Reply