Created
April 16, 2012 13:05
-
-
Save joshdholtz/2398665 to your computer and use it in GitHub Desktop.
Protocol Multipart Entity Snippet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Creates the boundary for the multipart, the content type with the boundary, and the entity | |
String boundary = "---------------------------14737809831466499882746641449"; | |
String contentType = "multipart/form-data; boundary=" + boundary; | |
HttpEntity entity = new ProtocolMultipartEntity(boundary, new File("/some/path")); | |
// Creates the post request | |
HttpPost httpPostFileRequest = new HttpPost(route); | |
httpPostFileRequest.addHeader("Content-Type", contentType); | |
httpPostFileRequest.setEntity(entity); | |
// Does the work | |
AbstractHttpClient httpClient = new DefaultHttpClient(); | |
HttpResponse httpResponse = httpClient.execute(httpUriRequest); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment