1
votes

We have an AWS account where we are using the S3 bucket to store encrypted images (jpgs). This bucket is Public and while we are able to upload all our images to this bucket successfully, 1 out of ~200-300 images we have uploaded/downloaded, always seems to fail to download with the following error:

Error downloading: Optional(“images/xxxxxxx/xxxxxxx.jpg") Error: Error Domain=com.amazonaws.AWSServiceErrorDomain Code=11 "(null)" UserInfo={HostId=xxxxxxx/xxxxxxx=, Message=Access Denied, Code=AccessDenied, RequestId=xxxxxxx}

This image (that fails download) is always uploaded using the same function and parameters as all the others, and downloaded the same way. The only unique thing about this image is that it is a profile photo in our app(android and iOS) and is just used in a different place. Nothing else is different about this image vs. the others that successfully download.

This issue has us confused about what we may be doing incorrectly, if anything at all. I am an AWS beginner.

1
If it is accessed from different place, make sure that you have amazon credentials set at that moment. Iet's say, your application starts from the screen, where avatar image needs to be requested. Request is started, but amazon credentials are not set yet. It will cause the problem you've described.fewlinesofcode
@KaushikMakwana: please do not add code formatting to proper nouns - they are not themselves code. Thanks!halfer
Sibin, please read Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers? - the summary is that this is not an ideal way to address volunteers, and is probably counterproductive to obtaining answers. Please refrain from adding this to your questions.halfer

1 Answers

0
votes

You might be uploading images to a bucket that is read-only and only admins can access it, In that case; add this before making a request:

s3PutObjectRequest.cannedACL = S3CannedACL.authenticatedRead()

This will grant you. permission over uploading files to a private bucket

There are many reasons to a access denied error, for example, you might have forgot this, add this to your plist and provide the suitable information to it:

<dict>
<key>CredentialsProvider</key>
<dict>
    <key>CognitoIdentity</key>
    <dict>
        <key>Default</key>
        <dict>
            <key>PoolId</key>
            <string>"My poll ID string"</string>
            <key>Region</key>
            <string>"PoolID Resign"</string>
        </dict>
    </dict>
</dict>
<key>S3TransferManager</key>
<dict>
    <key>Default</key>
    <dict>
        <key>Region</key>
        <string>"PoolID Resign"</string>
    </dict>
</dict>