1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Error writing to amazon s3 cloud

Discussion in 'Site & Server Administration' started by mstdmstd, Nov 9, 2017.

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

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

    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
    
    PHP:
    I searched more and found this https://wogan.blog/2017/01/04/use-amazon-s3-with-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/2ad57860552544212f6dac64203b861a/1509953635/50972/1194037/1.png
    https://imgur.com/a/oZyWN
    https://imgur.com/a/bKq0Y

    Full content of the policy :
    {
    "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/*"
    ]
    }
    ]
    }
    
    PHP:
    and https://imgur.com/a/xafqH

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


    SEMrush
    P.S.

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

    Describing the Policy I wrote :
    
    "Resource": [
    "arn:aws:s3:::nsnmed"
    ]
    },
    PHP:
    Of my bucket.

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

    Thanks!
     
    Last edited by a moderator: Nov 9, 2017
    mstdmstd, Nov 9, 2017 IP
    SEMrush
  2. RomanEpo

    RomanEpo Member

    Messages:
    94
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    43
    #2
    Yes..There are multiple permission option and setting.Did you resolve this issue ,If not try S3 Console >Bucket name > Permissions > Owner access permission.
     
    RomanEpo, Feb 22, 2018 IP