How to send image in REST API android
<p>Hi i am pretty new in android and i am building an App which take picture from camera and send this image to REST API.</p>

<p>I have created REST API but i get stuck how to pass image to REST API.I am using POST method in REST API but i don't know which media type i will pass in @Consumes annotation.</p>

<p>Is there any media type for image like there are other media types like (application/json, application/xml, etc).</p>

<p>Here is Code for REST API.</p>

<pre><code>import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import javax.ws.rs.Consumes;
import javax.ws.rs.Produces;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import com.sun.jersey.core.header.FormDataContentDisposition;
import com.sun.jersey.multipart.FormDataParam;

@Path("/files")
public class JerseyFileUpload {

    private static final String SERVER_UPLOAD_LOCATION_FOLDER = "/home/hassan/Downloads/";

    /**
     * Upload a File
     */

    @POST
    @Path("/upload")
    @Consumes()
    @Produces(MediaType.APPLICATION_JSON)
    public ImageUrl responseMsg(
            @FormDataParam("file") InputStream fileInputStream,
            @FormDataParam("file") FormDataContentDisposition contentDispositionHeader) {

        String filePath = SERVER_UPLOAD_LOCATION_FOLDER + contentDispositionHeader.getFileName();

        // save the file to the server
        saveFile(fileInputStream, filePath);

        String output =filePath;
        CompareImage cmp = new CompareImage();
        String id=cmp.get_image_comparison(output);
//      String [] arr = id.split(",");
//      String f_id = arr[0];
        ImageUrl img = new ImageUrl(output,id);
        return img;
        //return Response.status(200).entity(output).build();

    }

    // save uploaded file to a defined location on the server
    private void saveFile(InputStream uploadedInputStream,
            String serverLocation) {

        try {
            OutputStream outpuStream = new FileOutputStream(new File(serverLocation));
            int read = 0;
            byte[] bytes = new byte[1024];

            outpuStream = new FileOutputStream(new File(serverLocation));
            while ((read = uploadedInputStream.read(bytes)) != -1) {
                outpuStream.write(bytes, 0, read);
            }
            outpuStream.flush();
            outpuStream.close();
        } catch (IOException e) {

            e.printStackTrace();
        }

    }

}
</code></pre>

<p>Which media type should i use in <code>@Consumes()</code> for image.</p>

<p>Thanks in advance.</p>