Home>

I am trying to save an image to AWS S3, but I get the following error.

Error executing "PutObject" on "https://bucket.s3.ap-northeast-1.amazonaws.com/myprefix/image.jpeg";AWS HTTP error: Client error:PUT https: // bucket.s3.ap-northeast-1.amazonaws.com/myprefix/image.jpegresulted in a403 Forbiddenresponse:AccessDenied

As i am doing

AWS
IAM access permissions have been set.

Also set packet policy in S3.
With public access
"Block public access to authorized buckets and objects via the new public bucket policy"
Off

I did these things, but I'm having trouble with the above error. Are there any settings that are still missing?
I would appreciate your help.

I will add.
Use this article as a reference https://qiita.com/nobu0717/items/51dfcecda90d3c5958b8
I wrote in the controller as follows

$image = $request->file ('image');
// Upload to bucketmyprefixfolder
$path = Storage :: disk ('s3')->putFile ('myprefix', $image, 'public');
// Get the full path of the uploaded image
$image_path = Storage :: disk ('s3')->url ($path);

  • Answer # 1

    I think that you are using an access key (use of an access key is not recommended in the first place, but leave it in the first place), but make sure that the environment variable settings are correct. .

    Is there a mistake in the copy and paste (there is a space that I don't need, or the edges are missing)

    Is the bucket region correct?

    Is the bucket name correct?

    S3FullAccess should have PutObject authority, so it is highly possible that the authority cannot be referenced correctly.