I m using phonegap to bulid an application.I m using cordova 1.9.0.js .In the application I need to send images to the server. I m using the code avialable here for the client side:
http://docs.phonegap.com/en/1.0.0/phonegap_file_file.md.html#FileTransfer
The code shows correct number of byte sent in client logcat indicating that the file transfer was successful.
How will I recevie the image at server side. I am using restfulwebservice based of jaxrs on serverside.
Please help regarding the topic as i cannot find anything.
Thanks
Related
I am doing a project for image recognition. I want to send an image or a video from an android app to the raspberryPi, that is my server (I use flask), and make the recognition on the server and then send back the result to android. I want to do this with REST and python. So how can I do this?
I am new to all of this so any help is really helpful!
Yes, as your raspberryPi server use flask, so you can done the task through HTTP and your android phone browser as client.
raspberryPi as server should have the following api:
Chose a image and upload, then recognition and send the result back.
That all.
Since you are using flask, you need to implement REST endpoint that handles multipart/form-data, the example of such endpoint you can find here.
On the client part (in your case - android app) you need to implement sending of the image to that endpoint, example you can find here.
First of all bear with me as I'm new to both android applications and python flask.
I found sample code (java) on the web, which sends json data from an android application to a php web page (http://hmkcode.com/android-send-json-data-to-server/). What I want to do is to use this sample android code to send the data to a remote VPS server and use python flask as backend to receive and save the data .
As far as I understand the first thing that I have to replace is the php-address http://hmkcode.appspot.com/jsonservlet with my server's IP address (99.99.999.99) in the java code,
switch(view.getId()){
case R.id.btnPost:
if(!validate())
Toast.makeText(getBaseContext(), "Enter some data!", Toast.LENGTH_LONG).show();
// call AsynTask to perform network operation on separate thread
//new HttpAsyncTask().execute("http://hmkcode.appspot.com/jsonservlet");
new HttpAsyncTask().execute(99.99.999.99);
break;
}
Then I have to add the python flask code which will receive the data.
Concerning flask I found the following code which might apply to my issue,
https://github.com/javierchavez/Android-with-flask-backend/blob/master/Backend/wsgi.py.
Thus my questions are :
1st Is it correct to only replace the php-address with my VPS IP address, or do I also have to add the path to the flask file in my remote's server home directory.
2nd what would be the actual flask code, which will receive the data from the application and save it to the remote server (as far as I understand the python flask file will be saved in the VPS's home directory)
3rd do I also have to take into consideration the password required to access my VPS remote server when modifying the android and flask code?
Thank you in advance
Answering to the first question, it is correct to only specify the IP if the action you want to perform is declared on the root ("/") route of the flask server, otherwise you have to append the path you specify in the #app.route() tag.
I am currently working on a project whereby i need to send a request from an android application to my Arduino mega which in turns response back with the states of LEDs connnected to the Arduino. I have already implemented the GET request. However i need to know how to read the response back and how to send the string from the Arduino to the Android app.
Here is the code for the response:
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: application/json");
client.println("Connection: close");
client.println();
client.println("{\"status\":\"ok\"}"); // <--- how to create the string?
and also how to decode it from the android application. I have seen tutorials on the internet about using InputStream to do so but am unable to understand the code. Could you please help me on this.
You have to implement a Webserver on Arduino side and use a HTTP library (i.e. OkHTTTP) to connect to the Webserver.
I used OkHTTP on Android side but you could use other libraries too.
This link is something like you are looking for. It is from my blog.
Otherwise you can use aRest. It is very simple to use. If you want to know more give a look at this link from my blog.
I am trying to post data from my client android application to a django server.
for example I have User {login:---, email:---} and I wanna post them my LOCAL SERVER based on django.. what I should do ? any link or tutorial can be greatful, i can't find any thing really helpful.Thks
You need to make a HTTP request to your django server. Here is a similar question how to do a post request in android
I am using the Android 2.2 API. I want to know how to connect to a PostgreSQL database server.
I am new to this and so have no ideas, so please help me with some sample code.
You usually don't connect directly to a database.
To achieve the results you want, you can do a RESTful request.
This means, send either a JSON string or xml file to a server(which you can program in php, ruby and what not)
I'm not going to give you sample code cause there are literally tons of code on a simple google search "android restful login"
Example tutorial
The process is usually:
Enter login credentials on android device -> send post request to server -> validate credentials to the database(postgres in this case) -> send verification back -> android device act upon verification(usually by loading a new activity as a result if logged in successfully)