ȸ¿ø°¡ÀԡžÆÀ̵ð/ºñ¹øã±â
ȨÀ¸·Î


ÆÄÀÏ ¾÷·Îµå ¹× ÆĶó¸ÞÅÍ Àü¼Û (sending file & parameters by MultipartEntity - post)
7³â Àü
¡Ú ÆÄÀÏ°ú ÆĶó¸ÞÅÍ Á¤º¸ Àü¼Û (post)

¾Æ·¡ ¼Ò½º¸¦ »ç¿ëÇÏ·Á¸é ¾Æ·¡ ¸µÅ©¿¡¼­ ¾ÆÆÄÄ¡ ¶óÀ̺귯¸®¸¦ ´Ù¿î¹Þ¾Æ¾ß ÇÑ´Ù.
http://hc.apache.org/httpcomponents-client-ga/

//----------------------------------------------------
//ÆÄÀÏ Æû µ¥ÀÌÅÍ ½º·¹µå
//----------------------------------------------------
private class AsyncFileThread extends Thread {
    String address;
    File file;
    public AsyncFileThread(String addr, File _file){
        address = addr;
        file = _file;
    }
    
    public void run(){
        httpclient = new DefaultHttpClient();
        try {
            
            HttpPost post = new HttpPost(address);
            //Çì´õ ¼³Á¤
            post.setHeader("Connection", "Keep-Alive");
            post.setHeader("Accept-Charset", "UTF-8");
            post.setHeader("ENCTYPE", "multipart/form-data");
            //¸ÖƼÆÄÆ® ¿£Æ¼Æ¼ »ý¼º, ÆÄÀÏ À̸§ÀÌ ÇѱÛÀÏ °æ¿ì CharsetÀ» Á¤ÇÏ´Â °Ô ÁÁÀ½
            MultipartEntity multipartContent =
                new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE,
                null, Charset.forName("UTF-8"));
            //ÆÄÀÏ ºÙÀÓ
            FileBody cbFile = new FileBody(file);
            multipartContent.addPart("file1", cbFile);
            //ÆĶó¸ÞÅÍ
            for(NameValuePair nvp:nameValues){
                multipartContent.addPart(nvp.getName(),
                new StringBody(URLEncoder.encode(nvp.getValue(), HTTP.UTF_8)));
            }
            //ÆÄÀÏ »çÀÌÁî
            multipartContent.addPart("fileSize", new StringBody(String.valueOf(file.length())));
            //HttpPost Entity¿¡ ¿¬°á
            post.setEntity(multipartContent);
            
            //10ÃÊ ÀÀ´ä½Ã°£ ŸÀӾƿô ¼³Á¤
            HttpParams params = httpclient.getParams();
            params.setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
            HttpConnectionParams.setConnectionTimeout(params, 10000);
            HttpConnectionParams.setSoTimeout(params, 10000);
            
            //org.apache.http.client.HttpClient ·Î ½ÇÇà
            httpclient.execute(post, responseHandler);
            
        } catch (ConnectTimeoutException e){
            // ŸÀÓ ¾Æ¿ô ¿¬°á ¿¡·¯½Ã
            Message message = resultHandler.obtainMessage();
            Bundle bundle = new Bundle();
            bundle.putString(RESULT, TIMEOUT_RESULT);
            message.setData(bundle);
            resultHandler.sendMessage(message);
            stringData = e.toString();
            
         }  catch (Exception  e){
             // ±âŸ ¿À·ù½Ã
            Message message = resultHandler.obtainMessage();
            Bundle bundle = new Bundle();
            bundle.putString(RESULT, ERROR_RESULT);
            message.setData(bundle);
            resultHandler.sendMessage(message);
            stringData = e.toString();
        } finally {
            httpclient.getConnectionManager().shutdown();
        }
    }
}
ÃßõÃßõ : 266 Ãßõ ¸ñ·Ï
¹øÈ£ Á¦¸ñ
127
[Android] Intent È°¿ë ¿¹½Ã
126
Android ¼³Ä¡µÈ ¾îÇà ¸ñ·Ï PackageInfo¸¦ ÅëÇØ °¡Á®¿À±â ¹× ´Ù¸¥ ¾îÇà ½ÇÇà
125
[ANDROID(¾Èµå·ÎÀ̵å) ¾Û °³¹ß ±âÃÊ] MEDIAPLAYER À½¾Ç Àç»ýÇϱâ
124
[¾Èµå·ÎÀ̵å] ¿ÜºÎ ¾Û ½ÇÇà
123
¾Èµå·ÎÀÌµå ¼º´ÉÀ» À§ÇÑ ¼³°è
ÆÄÀÏ ¾÷·Îµå ¹× ÆĶó¸ÞÅÍ Àü¼Û (sending file & parameters by MultipartEntity / post)
121
MediaPlayer °¡·ÎÀÏ ¶§ UI ¼û±â°í Ç®½ºÅ©¸° ¸¸µé±â
120
À¥ºä¿¡¼­ html ÅÂ±× ¾ø¾Ö´Â ¹ý(Remove the html tag on loading web page in WebView)
119
´Ù¸¥ ¾Û ½ÇÇàÇϰųª Ç÷¹ÀÌ ½ºÅä¾î·Î À̵¿(Launch another app by code)
118
À¥ ºä¿¡¼­ ÅÂ±× Á¤º¸ ÃàÃâÇϱâ(Get the information of html tag in WebView of android)
117
ÀÚµ¿À¸·Î ¿¡µðÆ®ºä¿¡ Æ÷Ä¿½º µÇ´Â °Í ¸·±â
116
addJavascriptInterface ¿À·ù(Android WebView.addJavascriptInterface not Working)
115
Ä¿½ºÅÒ Å佺Ʈ ¶ç¿ì±â(To show Custom Toast)
114
À¥¿¡¼­ ÆÄÀÏ »çÀÌÁî¿Í ÄÜÅÙÆ®(ÄÁÅÙÃ÷) ŸÀÔ ¾Ë¾Æº¸´Â »ùÇÃÄÚµå
113
¾Èµå·ÎÀ̵å ÅؽºÆ® ºä¿¡¼­ Áö¿øÇÏ´Â HTML ű׵é
112
ÀÎÅÍ³Ý ÁÖ¼Ò À¯È¿¼º °Ë»ç (regular expression for url)
111
SpannableStringÀ¸·Î ÅؽºÆ® ºä¿¡ ¾ÆÀÌÄÜ ³Ö´Â ¹ý
110
½ÇÇà°¡´ÉÇÑ ¾Û ¸ñ·Ï (Get launchable apps in android)
109
HTMLÀ» ¾Èµå·ÎÀ̵å À¥ºä¿¡ ¸ðµÎ º¸ÀÌ°Ô Çϱâ Using WebView ViewPort in android
108
so ÆÄÀÏ ¾Èµå·ÎÀÌµå ½ºÆ©µð¿À¿¡¼­ »ç¿ëÇÏ´Â ¹ý
107
[¾Èµå·ÎÀ̵å] È­¸é »çÀÌÁî ±¸Çϱâ
106
[¾Èµå·ÎÀ̵å] ¾Èµå·ÎÀÌµå ½ºÆ©µð¿À¿¡¼­ ºôµå ÆÄÀÏ À̸§ ¼öÁ¤Çϱâ.
105
¿ÜºÎ ¾Û ½ÇÇà½ÃÅ°±â (launch external app in android)
104
Service & Notification(¾Ë¸²¹Ù¶ç¿ì±â) ÀÌ¿ëÇϱâ
103
È­¸é ȸÀü(rotation) ó¸®
102
[Android] Àüüȭ¸é, title bar ¾ø¾Ö±â, status bar ¾ø¾Ö±â
101
ANDROID(¾Èµå·ÎÀ̵å) ¾Û °³¹ß ±âÃÊ] MEDIAPLAYER À½¾Ç Àç»ýÇϱâ
100
[Android]MediaPlayer¿¡¼­ »ç¿îµå¸¦ Àç»ýÇÏ´Â µÎ °¡Áö °æ·Î
99
¾Èµå·ÎÀ̵å Intent »ç¿ë¹ý
98
¾Èµå·ÎÀ̵å È­¸é Á¤¸®
¸ñ·Ï
¹ÂÁ÷Æ®·ÎÆ® ºÎ»ê±¤¿ª½Ã ºÎ»êÁø±¸ °¡¾ßµ¿ ¤Ó °³ÀÎÁ¤º¸Ãë±Þ¹æħ
Copyright ¨Ï musictrot All rights reserved.