사진 및 비디오 촬영을위한 안드로이드 응용 프로그램을 만들고 있습니다. 이미지를 캡처 한 후 날짜와 일부 텍스트가있는이 이미지를 웹 서버에 보내려고합니다. 서버 측에서는이 사진과 비디오로 응용 프로그램을 만들고 있습니다. 캡처 된 이미지는 메모리 카드에 저장됩니다. JSON을 사용하여 텍스트가 포함 된 이미지를 보내려면 어떻게해야합니까? 또한 웹 서버에 비디오를 보내려고합니다.android에 서버에 이미지 및 비디오 보내기
4
A
답변
1
당신은 멀티 파트 POST 요청하여이 작업을 수행 할 수 있습니다 :이 mime4j 라이브러리를 추가해야
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(serverURL);
MultipartEntity postEntity = new MultipartEntity();
File file = new File("Your File path on SD card");
postEntity.addPart("fileupload", new FileBody(file, "image/jpeg"));
postEntity.addPart("loginKey", new StringBody(""+loginKey));
postEntity.addPart("message", new StringBody(message));
postEntity.addPart("token", new StringBody(token));
post.setEntity(postEntity);
response = client.execute(post);
(이 방법을 사용하면 JSON을 만들 필요가없는).
0
당신은 당신의 AsyncTask를이 코드를 사용할 수 있습니다
File file = new File("Your File path on SD card");
HttpClient httpclient = new DefaultHttpClient();
HttpPost httpost = new HttpPost("YourUrl");
MultipartEntity entity = new MultipartEntity();
entity.addPart("YourKey",new StringBody("Your Text"));
entity.addPart("File", new FileBody(file));
httpost.setEntity(entity);
HttpResponse response = httpclient.execute(httpost);
1
이이 AsyncTask를
FileBody filebodyVideo = new FileBody(new File(
"Sd Card VideoPath"));
FileBody filebodyVideo1 = new FileBody(new File("Video Upload url"));
StringBody Title= new StringBody("Put Title Here");
StringBody description= new StringBody("Put Desc Here");
MultipartEntity reqEntity = new MultipartEntity();
reqEntity.addPart("image", filebodyVideo);
multipartContent.addPart("Title", Title);
multipartContent.addPart("Description", description);
httppost.setEntity(multipartContent);
관련 문제
- 1. android에 알림을 보내기 위해 Firebase를 서버에 통합하십시오.
- 2. 서버에 업로드하기 전에 비디오 및 이미지 압축
- 3. 서버에 이미지 데이터 (NSData) 보내기
- 4. 오프라인/온라인으로 서버에 이미지 보내기
- 5. GWT 서버에 저장하려면 이미지 보내기
- 6. Android에 비디오 파일 저장
- 7. Android에 비디오 코덱 추가
- 8. 자바로 Android에 이메일 보내기
- 9. Android에 사용자 알림 보내기
- 10. 비디오 녹화 및 서버에 비디오 저장
- 11. Android에 서버에 게시
- 12. android에 서버에 asp.net SQL 서버에 연결
- 13. 서버에 객체 및 명령 보내기
- 14. 노드 서버에 이미지 보내기 및 OCR Microsoft 비전 API 호출
- 15. PHP/GD 라이브러리 Imagettftext 서버에 이미지 저장 및 브라우저로 보내기
- 16. 비디오 및 이미지 표시
- 17. Retrofit 2 서버에 이미지 배열 보내기
- 18. Poco를 웹 서버에 사용하여 이미지 보내기
- 19. android는 서버에 보내기 전에 이미지 크기를 압축합니다.
- 20. 큰 파일을 Android에 서버에 업로드 하시겠습니까?
- 21. 보내기 및 이미지
- 22. 비디오 및 이미지 업로드 서버
- 23. android에 이미지 업로드
- 24. Android에 비디오 화면이 표시되지 않습니다.
- 25. android에 비디오 (mp4) 파일로드 중
- 26. android에 이미지 저장하기
- 27. android에 텍스트가있는 인라인 이미지
- 28. blob android에 이미지
- 29. android에 DICOM 이미지 표시
- 30. 이미지 및 비디오 정보, PHP
에서 서버에 텍스트, 이미지를 uplaod 시도는 파일 – Ameer
모든 종류의 가능 예 ... 이미지 또는 비디오 ... 작동합니다 :) – amalBit
PDF 파일은 무엇입니까 – Ameer