Error writing to amazon s3 cloud

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
mstdmstd
New php-forum User
New php-forum User
Posts: 32
Joined: Sun Mar 30, 2014 4:45 am

Thu Nov 09, 2017 8:36 am

Hi all,
In my laravel 5 application I have amazon s3 cloud usage, like:

Code: Select all

use Storage;
...
$s3 = Storage::disk('s3');
$uploaded = $s3->put($upload_path, file_get_contents($this->file), 'public');
But but uploading my file I got errot :

Code: Select all

S3Exception in WrappedHttpHandler.php line 192:
Error executing "PutObject" on "https://nsnmed.s3-us-west-2.amazonaws.com/uploads/OperationFile/24/1509953227-1.pdf"; AWS HTTP error: Client error: `PUT https://nsnmed.s3-us-west-2.amazonaws.com/uploads/OperationFile/24/1509953227-1.pdf` resulted in a `403 Forbidden` response:
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>F59F73 (truncated...)
AccessDenied (client): Access Denied - <?xml version="1.0" encoding="UTF-8"?>
<Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>F59F7304DABAE9F7</RequestId><HostId>hFPo7S53x3DpmnndlKNe7hR5r1raq+qKn4asoNNVTOdGwS7KlQ0RmyVRE8LCYUOGedJjNRZuiOk=</HostId></Error>
in WrappedHttpHandler.php line 192
at WrappedHttpHandler->parseError(array('exception' => object(ClientException), 'connection_error' => false, 'response' => object(Response)), object(Request), object(Command), array()) in WrappedHttpHandler.php line 97
at WrappedHttpHandler->Aws\{closure}(array('exception' => object(ClientException), 'connection_error' => false, 'response' => object(Response))) in Promise.php line 203
at Promise::callHandler('2', array('exception' => object(ClientException), 'connection_error' => false, 'response' => object(Response)), array(object(Promise), object(Closure), object(Closure))) in Promise.php line 174
at Promise::GuzzleHttp\Promise\{closure}(array('exception' => object(ClientException), 'connection_error' => false, 'response' => object(Response))) in RejectedPromise.php line 40
at RejectedPromise::GuzzleHttp\Promise\{closure}() in TaskQueue.php line 47
at TaskQueue->run() in CurlMultiHandler.php line 96
at CurlMultiHandler->tick() in CurlMultiHandler.php line 123
at CurlMultiHandler->execute(true) in Promise.php line 246
at Promise->invokeWaitFn() in Promise.php line 223
at Promise->waitIfPending() in Promise.php line 267
at Promise->invokeWaitList() in Promise.php line 225
at Promise->waitIfPending() in Promise.php line 267
at Promise->invokeWaitList() in Promise.php line 225
at Promise->waitIfPending() in Promise.php line 62
at Promise->wait() in S3ClientTrait.php line 33
at S3Client->upload('nsnmed', 'uploads/OperationFile/24/1509953227-1.pdf', '%PDF-1.3 %���� 194 0 obj << /Linearized 1 /L 1257876 /H [ 993 279 ] /O 197 /E 263192 /N 33 /T 1253877 >> endobj xref 194 11 0000000016 00000 n 0000000598 00000 n 0000000655 00000 n 0000001272 00000 n 0000001411 00000 n 0000001512 00000 n 0000001684 00000 n 00000017

I searched more and found this https://wogan.blog/2017/01/04/use-amazo ... laravel-5/ description and some other links.
According to it I created bucket, IAM User, Group and Policy and attached my IAM User to the Group and Policy.

Several printscreens from my aws s3 creditials:

https://imgur.com/a/9UGO2
http://i.piccy.info/i9/2ad5786055254421 ... 4037/1.png
https://imgur.com/a/oZyWN
https://imgur.com/a/bKq0Y

Full content of the policy :

Code: Select all

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "s3:ListBucket",
                "s3:ListAllMyBuckets",
                "s3:GetBucketLocation"
            ],
            "Resource": [
                "arn:aws:s3:::nsnmed"
            ]
        },
        {
            "Effect": "Allow",
            "Action": [
                "s3:PutObject",
                "s3:GetObject",
                "s3:DeleteObject"
            ],
            "Resource": [
                "arn:aws:s3:::nsnmed/*"
            ]
        }
    ]
}
and https://imgur.com/a/xafqH

Could you please give me a hint which option did I miss ?



P.S.

Creating new user I checked "Programmatic access" option and left “AWS Management Console access” option unchecked

Describing the Policy I wrote :

Code: Select all

"Resource": [
                "arn:aws:s3:::nsnmed"
            ]
        },
Of my bucket.

I did not find where to specify where user has permissions to access my bucket ? If there is such option ?

Thanks!

Post Reply