Page 1 of 1

How do i set up my camera service to send the pictures to my server?

Posted: Sat Jun 15, 2013 3:39 am
by John Herdean

Im trying to figure out how to send the pics the user just took with the phone to send them to my server? I also mapped to local storage the asset value of the image that i also mapped to display on the screen.

I thought maybe I create a REST service to map to the local storage variable i saved the pic in and send it as a request parameter, but when Im setting up the REST service I'm looking for a multi-part/form - content type. The only options there are:

1) json
2) xml OR
3) x-www-forum-urlencoded

which one of those options would it be?

OR, do I do i create another camera service, and if so, I cant edit any request parameters so how would add map the image asset?


How do i set up my camera service to send the pictures to my server?

Posted: Sat Jun 15, 2013 3:52 am
by maxkatz

The Camera service (based on PhoneGap) only takes an image, it doesn't upload it. You can see how to upload here: https://getsatisfaction.com/apperyio/...


How do i set up my camera service to send the pictures to my server?

Posted: Sat Jun 15, 2013 4:28 am
by John Herdean

what are you saying? that I cannot return this pics to my own server, I have to use appery's database?


How do i set up my camera service to send the pictures to my server?

Posted: Sat Jun 15, 2013 4:42 am
by maxkatz

You can use any service and upload files/data to any service. That's the example that we have.

This is another example that uses JavaScript: http://docs.appery.io/tutorials/uploa.... You can update it to upload to your service.


How do i set up my camera service to send the pictures to my server?

Posted: Mon Jun 17, 2013 8:31 pm
by John Herdean

it seem to me that both of them tell you how to use Appery's database. How would I set up a REST service that I'm looking for a multi-part/form - content type??


How do i set up my camera service to send the pictures to my server?

Posted: Mon Jun 17, 2013 8:34 pm
by maxkatz

We don't know how your service works.. you can look at the examples I provided and adapt for your service. This is something you will need to code.


How do i set up my camera service to send the pictures to my server?

Posted: Mon Jun 17, 2013 8:37 pm
by John Herdean

uhmm, the only thing i found in there that might work, but not sure is running this JS:

var file;
function fileSelectHandler(e) {
var files = e.target.files || e.dataTransfer.files;
file = files[0];
previewFile();
}

function upload() {
var serverUrl = 'https://api.appery.io/rest/1/db/files/' + file.name;

Code: Select all

 $.ajax({ 
     type: "POST", 
     beforeSend: function(request) { 
         request.setRequestHeader("X-Appery-Database-Id", FileDB_settings['database_id']),              
         request.setRequestHeader("X-Appery-Session-Token", localStorage.getItem('token')), 
         request.setRequestHeader("Content-Type", file.type); 

     }, 
     url: serverUrl, 
     data: file, 
     processData: false, 
     contentType: false, 
     success: function(data) { 

         // OPTIONAL, this is the file name under which the image was stored in database.... 
         // localStorage.setItem('db_file_name', file.name); 

      }, 
     error: function(data) { 
         // do something in case of an error... 
     } 
 }); 

}


How do i set up my camera service to send the pictures to my server?

Posted: Mon Jun 17, 2013 8:38 pm
by John Herdean

I'm assuming that I would change Appery's url's to my aws server??


How do i set up my camera service to send the pictures to my server?

Posted: Mon Jun 17, 2013 8:40 pm
by John Herdean

also, If I have the files in localSTorage, then how would it affect the code?


How do i set up my camera service to send the pictures to my server?

Posted: Mon Jun 17, 2013 8:45 pm
by maxkatz

As I said, I don't know how your service works. Yes, you would need to point the service URL to your server.