I never had to send media files to the server. Plain text data sent as follows:

HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(Application.TEST_API + Application.TEST_API_IDENTIFIER); httppost.setHeader(HTTP.CONTENT_TYPE, "application/x-www-form-urlencoded;charset=UTF-8"); List<NameValuePair> valuePairs = new ArrayList<>(); valuePairs.add(new BasicNameValuePair("request", "save_profiles_result")); valuePairs.add(new BasicNameValuePair("profiles", jsonProfiles)); httppost.setEntity(new UrlEncodedFormEntity(valuePairs, "UTF-8")); HttpResponse httpResponse = httpclient.execute(httppost); 

But right now, I have a completely different task, I just can’t figure out how to insert

 String outputpath = VideoRecordConfig.getOutputMediaFile( VideoRecordConfig.MEDIA_TYPE_VIDEO).getAbsolutePath(); 

Type like this, only here the outputpath just the name of the file

 valuePairs.add(new BasicNameValuePair("video", outputpath )); 

ValuePairs you please tell me how to insert a video in ValuePairs ? Maybe this will seem like a silly question to someone, but I don’t browse at all in media files!

    1 answer 1

    When transmitting binary data via HTTP using a POST request, multipart is usually used.

    I would also recommend using the Retrofit library to communicate with the server.

    • Please try to publish detailed answers containing a specific example of the minimum solution, supplementing them with a link to the source. Answers –references (like comments) do not add knowledge to Runet. - Nicolas Chabanovsky