In my android application I need to send a png file to my server. I'm currently using volley. What's the best way to send a file? I'm doing this now
final File file = new File(filename);
if (!file.exists()) {
Log.d(TAG, "Signature file does not exists.");
return;
}
final StringRequest stringRequest = new StringRequest(Request.Method.POST, Global.url_image_test, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Log.d(TAG, "Server is running..." + " " + response);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.d(TAG, "Unable to talk with server :(");
}
}) {
@Override
public byte[] getBody() throws AuthFailureError {
byte[] dataBase64 = Base64.encode(file.toString().getBytes(), Base64.DEFAULT);
return dataBase64;
}
};
It's the right way to send the file? How can get the file on the server side using nodejs and express?