Hi Slava,
To upload image you use service galery_shot, that is a CameraService in fact. Please try the code from this thread: https://getsatisfaction.com/apperyio/...
Hi Slava,
To upload image you use service galery_shot, that is a CameraService in fact. Please try the code from this thread: https://getsatisfaction.com/apperyio/...
Hi,
Sorry if i didnt understand the answer..
I do use the gallery_shot service which is a CameraService. From it i get a Base64 image data.
Once i have it, i convert it to a Blob and then invoke the ajax to try and upload it.. but i get "Bad Request" error every time.
I did refer to the given thread before (with the resize stuff) but i didnt see there where he uses a camera service for the upload.
I also tried to use your new upload files function but the result is the same.
Is it possible that the image is just to big or something? If it is, how do i resize it? In the other thread it takes the data from the tag... which i dont have, or rather dont know how to sent my image to..
Hello!
We are sorry for a late reply. Could you try to debug app using Weinre debugger and let us know result http://devcenter.appery.io/documentat...?
Hi,
Sorry for not answering for a long time. I've tried debugging it but i didnt come up with something. The problem is that once i try to user the AJAX call, it fails with bad request. It doesnt give me any more info.
The data that i'm trying to send looks similar to the one in the tutorial using the 'input' tag so i dont know whats wrong.
Is it possible that you'll try to implement a simple upload app using the camera service?
I mean, the app will contain a button that opens up the phone gallery / camera.
Takes a picture.
It will put the picture in a picture box.
Then a button that will upload that data to the files DB collection.
Thanks
Hello Slava,
1 Change destinationType for camera service: http://prntscr.com/3oy7fa
2 On sucess event create javascript code:
codevar file = File(data.imageURI);
uploadPhoto(data.imageURI);
function uploadPhoto(imageURI) {
var options = new FileUploadOptions();
options.fileKey=imageURI.substr(imageURI.lastIndexOf('/')+1);
options.fileName=imageURI.substr(imageURI.lastIndexOf('/')+1);
options.mimeType="image/jpeg"
var params = {
Code: Select all
headers: { 'X-Appery-Database-Id': "530dasde4e16aaaa4222e7",
'X-Appery-Session-Token': localStorage.getItem('token')}
}; 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) {
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);
} /code
Thank you!
Works perfectly now =]]