I am using android aws dependency com.amazonaws:aws-android-sdk-s3:2.6.+
我正在使用android aws依赖com.amazonaws:aws-android-sdk-s3:2.6。+
While uploading Image getting error as bellow
上传图片获取错误时如下所示
com.amazonaws.services.s3.model.AmazonS3Exception: Access Denied (Service: Amazon S3; Status Code: 403; Error Code: AccessDenied; Request ID: XXXXXXXXXXX), S3 Extended Request ID:XXXXXXXXXXXX
com.amazonaws.services.s3.model.AmazonS3Exception:拒绝访问(服务:Amazon S3;状态代码:403;错误代码:AccessDenied;请求ID:XXXXXXXXXXX),S3扩展请求ID:XXXXXXXXXXXX
Here is the Code for uploading Image
这是上传图片的代码
private void beginUpload(String filePath, final String mediaCaption,
Message message,boolean isThumb,final
UploadFileToStorageCompletionListener listener) {
getLogger().log(Strings.TAG, "########## 3: " + filePath);
//construct a bucket path
final String fullBucketPath =
constructBucketPath(message.getMediaType(), message.getId(),
isThumb);
File file = new File(filePath);
mObserver = mTransferUtility.upload(fullBucketPath, mediaCaption,
file);
mObserver.setTransferListener(new TransferListener() {
@Override
public void onStateChanged(int id, TransferState state) {
getLogger().log(Strings.TAG," onStateChanged() " + state);
if (state.equals(TransferState.COMPLETED)) {
listener.onUploadSuccess(fullBucketPath);
}
}
@Override
public void onProgressChanged(int id, long bytesCurrent, long bytesTotal) {
getLogger().log(Strings.TAG,"onProgressChanged() " + bytesCurrent + "/" + bytesTotal);
dismissProgressDialog();
}
@Override
public void onError(int id, Exception ex) {
listener.onDatabaseError(new FirebaseFailure(ex));
getLogger().log(Strings.TAG, "onError() " + ex.getMessage());
}
});
}
2 个解决方案
#1
0
First, need to check the permissions for the s3 bucket. And go to the bucket policy and check the json object which is permissions for put, get and post.
首先,需要检查s3存储桶的权限。然后转到存储桶策略并检查json对象,该对象是put,get和post的权限。
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AddPerm",
"Effect": "Allow",
"Principal": "*",
"Action": [
"s3:PutObject",
"s3:GetObject"
],
"Resource": "arn:aws:s3:::{FILE NAME}/*"
}
]
}
Try the above permissions.
尝试以上权限。
#2
0
You need to check whether the user [ Access Key & Secret Key ] for the current configs you are using has the permission to use the S3
. You can check the detail information, or goto your IAM for changing permissions, for detail regarding IAM visit this
您需要检查您使用的当前配置的用户[访问密钥和密钥]是否具有使用S3的权限。您可以查看详细信息,或转到IAM以更改权限,以获取有关IAM访问此内容的详细信息
For the starter try with S3 Full Access
对于使用S3 Full Access的入门尝试
Hope this helps
希望这可以帮助
#1
0
First, need to check the permissions for the s3 bucket. And go to the bucket policy and check the json object which is permissions for put, get and post.
首先,需要检查s3存储桶的权限。然后转到存储桶策略并检查json对象,该对象是put,get和post的权限。
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AddPerm",
"Effect": "Allow",
"Principal": "*",
"Action": [
"s3:PutObject",
"s3:GetObject"
],
"Resource": "arn:aws:s3:::{FILE NAME}/*"
}
]
}
Try the above permissions.
尝试以上权限。
#2
0
You need to check whether the user [ Access Key & Secret Key ] for the current configs you are using has the permission to use the S3
. You can check the detail information, or goto your IAM for changing permissions, for detail regarding IAM visit this
您需要检查您使用的当前配置的用户[访问密钥和密钥]是否具有使用S3的权限。您可以查看详细信息,或转到IAM以更改权限,以获取有关IAM访问此内容的详细信息
For the starter try with S3 Full Access
对于使用S3 Full Access的入门尝试
Hope this helps
希望这可以帮助