【发布时间】:2020-04-27 19:41:56
【问题描述】:
我从 Lambda 获取预签名 URL,但不知道为什么当我向生成的 URL 发出 PUT 请求时,我的图像没有上传到 S3。
我完全遵循了这两个答案,但它仍然不适合我
https://stackoverflow.com/a/46177449/11110509
https://stackoverflow.com/a/46579224/11110509
谁能指出我做错了什么?
public interface IUploadImages{
@PUT
Call<String> listRepos(@Url String url, @Body RequestBody image);
}
还有我上传图片的电话:
//Already checked to make sure mImageUri is not null
File file = new File(StringUtils.getPath(this, mImageUri));
RequestBody requestFile = RequestBody.create(MediaType.parse("image/jpeg"), file);
RetrofitInterfaces.IUploadImages service = RetrofitClientInstance.getRetrofitInstance()
.create(RetrofitInterfaces.IUploadImages.class);
//Also checked to make sure mGeneraredUrl is also not null
Call<String> call = service.listRepos(mGeneratedUrl, requestFile);
call.enqueue(new Callback<String>() {
@Override
public void onResponse(Call<String> call, Response<String> response) {
if(response.isSuccessful()){
Log.d(TAG, "onResponse: Success?");
}
}
@Override
public void onFailure(Call<String> call, Throwable t) {
Log.d(TAG, "onFailure: Failed: " + t);
}
});
我已将存储桶公开。调用没有失败,但在 onResponse 中我得到的响应代码为 403。
【问题讨论】:
-
能否添加错误日志(在
onFailure()中添加 t.printstackTrace())? -
通话没有失败,但我收到 403 错误
标签: android amazon-web-services amazon-s3 retrofit retrofit2