0
내 응용 프로그램에서 비디오 파일을 업로드하려고합니다.retrofit2 업로드 파일
는 여기에 지금까지있어 무엇 :
public class Download extends Application {
public interface upload {
@Multipart
@POST("new")
Call<Response> send(@Part("myFile") RequestBody file);
}
public void uploadFile(File xfile) {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://192.168.0.3")
.addConverterFactory(GsonConverterFactory.create())
.build();
RequestBody file = RequestBody.create(MediaType.parse("video/*"), xfile);
upload xUpload = retrofit.create(upload.class);
Call<Response> call = xUpload.send(file);
try {
Response result = call.execute().body();
}
catch (IOException e)
{
Log.d("TEST3", " didn't work ");
}
}
}
나는 다음과 같은 오류 retrofit2.Response를 얻을 '유효한 응답 본문의 형식이 아닙니다. ResponseBody를 의미 했습니까? 방법 upload.send에 대한 아이디어가
나는 retrofit2 웹 페이지를 읽고 파일 업로드에 대한 주요 예제를 시도했지만 두 가지 이유로 작동하지 않습니다. 1. ServiceGenerator를 찾을 수 없습니다. 2. 내 파일을 갤러리에서 찾았습니다. 업로드 할 임시 파일에 내용을 스트리밍했습니다. URI에서 직접 액세스 할 수 없습니다 ... 또는 retrofit2로 할 수 있을까요?
https : // futur estud.io/tutorials/retrofit-2-how-to-upload-files-to-server – AnixPasBesoin
최근에이 튜토리얼을 따라 파일 업로드를 완료했습니다 https://futurestud.io/tutorials/retrofit-2-passing-multiple -parts-along-a-file-with-partmap – rajesh