Android에서 새로 생겼습니다. wifi와 gprs를 통해 파일을 업로드하고 싶지만 문제는 어떻게 Android에서 다중 부분 데이터를 보낼 수 있는가입니다.Android 용 파일 업로드
0
A
답변
0
link에 대한 세부 정보는 이동해야합니다. 이것은 비슷한 질문입니다.
0
HttpConnection을 만들고 서버에 스트림을 전달합니다. 따르십시오 link
1
// Enable HTTP parameters
HttpParams sslparams = new BasicHttpParams();
HttpProtocolParams.setVersion(sslparams, HttpVersion.HTTP_1_1);
HttpProtocolParams.setContentCharset(sslparams, HTTP.UTF_8);
// Register the HTTP and HTTPS Protocols. For HTTPS, register our custom SSL Factory object.
SchemeRegistry registry = new SchemeRegistry();
registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
registry.register(new Scheme("https",sslFactory, 443));
// Create a new connection manager using the newly created registry and then create a new HTTP client
// using this connection manager
ClientConnectionManager ccm = new ThreadSafeClientConnManager(sslparams, registry);
httpclient = new DefaultHttpClient(ccm,sslparams);
HttpPost httppost = new HttpPost(url);
/*httppost.setEntity(new UrlEncodedFormEntity(nameValue));
httppost.setEntity(new InputStreamEntity(new FileInputStream(file), file.length()));
httppost.setHeader("Content-Type", "application/x-www-form-urlencoded");*/
MultipartEntity entity = new MultipartEntity();
//entity.addPart("fileName",);
entity.addPart("file", new InputStreamBody(new FileInputStream(file), ContentType.APPLICATION_OCTET_STREAM));
entity.addPart("UserID", new StringBody(parameter.getUsreId()));
entity.addPart("UserName",new StringBody(parameter.getUserName()));
entity.addPart("HostName", new StringBody(parameter.getHostName()));
entity.addPart("ProtectionType", new StringBody(parameter.getProtectionType()));
entity.addPart("FolderPath", new StringBody(parameter.getFolderPath()));
entity.addPart("osid", new StringBody(parameter.getOsId()));
//entity.addPart("file", new FileBody(file,ContentType.MULTIPART_FORM_DATA));
httppost.setEntity(entity);
//httppost.setEntity(new StringEntity(file));
//httppost.setHeader("Content-Type", "text/xml");
HttpParams httpparams = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(httpparams, 15000);
HttpConnectionParams.setSoTimeout(httpparams, 30000);
httppost.setParams(httpparams);
HttpResponse response = httpclient.execute(httppost);
관련 문제
- 1. Android 용 원격 서버에 파일 업로드
- 2. 업로드 용 파일 예약
- 3. Android 파일 서버에 업로드
- 4. BlackBerry 용 Rackspace에 파일 업로드
- 5. Android 용 인터페이스 파일 용 XML 파일
- 6. 원격 파일 용 파일 업로드 버튼
- 7. Android, Tomcat 서버에 파일 업로드
- 8. WebView Android 4.0 파일 업로드
- 9. android httpservice 브라우저에서 파일 업로드
- 10. Android 용 OpenCV APK 용 중복 파일
- 11. Android 용 JSON 파일 쓰기
- 12. 파일 업로드 용 사용자 정의 단추 텍스트
- 13. TinyMCE 용 PDW 파일 브라우저 - 업로드 경로
- 14. 업로드 용 PHP 임시 파일 이름이 충돌합니다.
- 15. 업로드 된 파일 용 PHP Listener
- 16. C# 간단한 파일 서버 (업로드 용)
- 17. iOS - 보관 용 파일 업로드 (사용자 로그인)
- 18. Android 용 코드 파일/XML 파일 구성
- 19. android asynctask 보관함에 여러 파일 업로드
- 20. Android NDK : NDK를 사용한 파일 업로드
- 21. Android가 데스크톱 PC에서 Android 기기로 파일 업로드
- 22. Tastypie Django with Android 클라이언트로 파일 업로드
- 23. mySQL 용 다중 파일 업로드 파일 스크립트가 필요합니다.
- 24. 업로드 용 AJAX 코드
- 25. Eclipse DDMS 파일 탐색기 파일 업로드 중 (표시하지 않음)
- 26. 클릭시 JQuery 파일 업로드
- 27. Symfony2 : 파일 업로드 플러그인을 사용하여 파일 업로드
- 28. 풍부한 : 파일 업로드 : 파일 업로드 ViewExpiredException
- 29. PHP 컬 파일 업로드 버튼이있는 파일 업로드
- 30. 큰 파일 업로드 이력서로
저는 첫 번째 질문의 답을 알고 기쁩니다. 그것은 내가 원하는 것입니다. 시기 적절한 답변을 주셔서 감사합니다. – Leo