当我尝试使用Retrofit2时,它向我显示错误。错误为 okhttp3.call没有Fileinfo
这是 MainActivity.java 文件中的我的错误部分
public void onClick(View v) {
File file = new File(imagePath);
RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"),file);
MultipartBody.Part body = MultipartBody.Part.createFormData("file",file.getName() , requestBody);
Call<FileInfo> call = fileService.upload(body);
((retrofit2.Call) call).enqueue(new Callback<FileInfo>() {
@Override
public void onResponse(Callback<FileInfo> call, Response<FileInfo> response) {
if(response.isSuccessful()){
Toast.makeText(MainActivity.this,"Image upload success", Toast.LENGTH_SHORT).show();
}
}
@Override
public void onFailure(Callback<FileInfo> call, Throwable t) {
Toast.makeText(MainActivity.this, "ERROR: " + t.getMessage(),Toast.LENGTH_SHORT).show();
}
});
}
此处的错误代码块的屏幕截图