Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- No response from server when uploading video
- HttpClient client = new DefaultHttpClient();
- client.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
- HttpPost post = new HttpPost(url);
- MultipartEntity entity = new MultipartEntity( HttpMultipartMode.BROWSER_COMPATIBLE );
- File file= new File(sourceFileUri);// sourceFileUri is a String variable , contains the path of video
- FileBody bin = new FileBody(file);
- // For usual String parameters
- entity.addPart( "name", new StringBody( "xxxxx", "text/plain",
- Charset.forName( "UTF-8" )));
- entity.addPart( "Phone", new StringBody( "0023451234", "text/plain",
- Charset.forName( "UTF-8" )));
- entity.addPart( "file", bin);
- post.setEntity( entity );
- // Here we go!
- // String response = EntityUtils.toString( client.execute( post ).getEntity(), "UTF-8" );
- HttpResponse response = client.execute(post);
- HttpEntity resEntity = response.getEntity();
- if (resEntity != null) {
- Toast.makeText(getApplicationContext(),EntityUtils.toString(resEntity), Toast.LENGTH_SHORT).show();
- Log.i("RESPONSE",EntityUtils.toString(resEntity));
- }
- }
- catch (Exception e) {
- e.printStackTrace();
- }
Add Comment
Please, Sign In to add comment