在同事的帮助下,这就是解决方案。
public interface UpdateImageInterface { @PUT Call<Void> updateImage(@Url String url, @Body RequestBody image);}调用代码:
String CONTENT_IMAGE = "image/jpeg"; File file = new File(localPhotoPath); // create new file on device RequestBody requestFile = RequestBody.create(MediaType.parse(CONTENT_IMAGE), file); Retrofit retrofit = new Retrofit.Builder() .baseUrl("http://www.dummy.com/") .build(); UpdateImageInterface imageInterface = retrofit.create(UpdateImageInterface.class); // imageUrl is the String as received from AWS S3 Call<Void> call = imageInterface.updateImage(imageUrl, requestFile);Javadoc,获取有关
@Url(类网址)和
baseUrl()(类Retrofit.Builder)的信息
MediaType是OkHttp库中的一个类,通常与Retrofit(均来自Square)一起使用。可以在Javadoc中找到有关传递给parse方法的常量的信息。



