Skip to content Skip to sidebar Skip to footer

How To Convert Video File(.mp4) Format Into Binary Format In Android?

I want to upload a video in web server. I got the service which to i want to pass a file in binary format how can i do this ? I have tried to convert the video file into binary for

Solution 1:

I have experienced in my 3 application that it is good if use XML to send the IMAGE or VIDEO over server. Sending IMAGE or VIDEO in the form of base64 String in the XML is best if you want to upload a IMAGE or VIDEO in ANDROID.

public static String uploadMultiplePhoto(String url, String xmlString) {
        String responseString = "";
        try {
            //instantiates httpclient to make request
            DefaultHttpClient httpclient = new DefaultHttpClient();
            //url with the post data
            HttpPost request = new HttpPost(url);
            //convert parameters into JSON object
            //JSONObject holder = new JSONObject(jsonObjString);

            //passes the results to a string builder/entity
            StringEntity se = new StringEntity(xmlString);
            //sets the post request as the resulting string
            request.setEntity(se);
            //sets a request header so the page receving the request
            //will know what to do with it
            request.setHeader("Accept", "application/xml");
            /*request.setHeader("Content-type", "application/xml");*/

            //Handles what is returned from the page
            ResponseHandler<String> responseHandler = new BasicResponseHandler();
            responseString = httpclient.execute(request, responseHandler);
        } catch (Exception exception) {
            exception.printStackTrace();
        }
        return responseString;
    }

Post a Comment for "How To Convert Video File(.mp4) Format Into Binary Format In Android?"