출처 : http://blog.tacticalnuclearstrike.com/2010/01/using-multipartentity-in-android-applications/
Using MultipartEntity in Android applications
To be able to upload files from an Android application and use the Multipart content type you need to add some additional jar files to your application.
The files needed are apache-mime4j, httpclient, httpcore and httpmime. All are opensource projects built by the Apache foundation.
Download the 4 files and add them to your project then you should be able to use the following code to post strings and files to pages.
01
02
03
04
05
06
07
08
09
10
11
12
13 |
HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost( "http://www.tumblr.com/api/write" ); try { MultipartEntity entity = new MultipartEntity(); entity.addPart( "type" , new StringBody( "photo" )); entity.addPart( "data" , new FileBody(image)); httppost.setEntity(entity); HttpResponse response = httpclient.execute(httppost); } catch (ClientProtocolException e) { } catch (IOException e) { } |
The image variable in this case is a File that contains an image captured by the camera on the phone.
'Android > Tip&Tech' 카테고리의 다른 글
android 영문키보드 나오게 하기 (0) | 2011.07.11 |
---|---|
안드로이드 네트워크 상태 확인 및 변경 브로드케스트 (0) | 2011.07.11 |
android http/post/mulitipart (0) | 2011.07.08 |
안드로이드 에서 웹으로 업로드 함 (0) | 2011.07.08 |
overridePendingTransition 설명 (0) | 2011.07.08 |