Crystal Taggart
Posts: 0
Joined: Tue Aug 26, 2014 3:16 am

Problems with CamFind API

How can I upload a photo to the camfind API? Here's the CURL Command that I'm trying to run through jquery ajax:
curl -X POST --include 'https://camfind.p.mashape.com/image_r...' \
-H 'X-Mashape-Key: XXXXXXXXXXX \
-F 'focus[x]=480' \
-F 'focus[y]=640' \
-F 'image_request[altitude]=27.912109375' \
-F 'image_request[image]=@apple-1.jpg' \
-F 'image_request[language]=en' \
-F 'image_request[latitude]=35.8714220766008' \
-F 'image_request[locale]=en_US' \
-F 'image_request[longitude]=14.3583203002251'

I've tried this multiple ways including using the cordova upload plugin.

Here's my latest attempt (in the success event of the CameraService):

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

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

navigator.camera.getPicture(success, fail, {quality: 80, sourceType: src});

function success(imageData) {
alert ('inSuccess'); //this isn't firing?
var url="https://camfind.p.mashape.com/image_r...";

$.ajax({
url: url,
type: 'post',
data: {
'image_request[image]': imageURI.substr(imageURI.lastIndexOf('/')+1),
'image': imageData
},
headers: {
'X-Mashape-Key': 'xxxxxxxxxxxxx'
},
dataType:'json',
success: function (data) {
alert(data);
}
});

}

What am I missing?

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Problems with CamFind API

Hello,

Please follow these topics:
http://blog.bismallion.com/appery-sen...
http://blog.bismallion.com/sending-em...

There are examples of file uploading via JS.

Return to “Issues”