Unable to save image to Amazon S3 using Ravel

Asked 2 years ago, Updated 2 years ago, 118 views

I wanted to save the image on Amazon S3, but I cannot save it due to the error below.
Permission granted.

put produces an error when sending a file:

Error when sending file with put.

The .env access key and the secret access key are correct, so I don't think that's relevant.

Enter a description of the image here

By the way, you can retrieve images from the bucket as follows:

Enter a description of the image here

You can get the image information from the S3 bucket, but you cannot put it.Please let me know if there is any possible cause.

view file

<form action="{{route('upload')}}" method="post" enctype="multipart/form-data">
              {{ csrf_field()}}
              <input type="file" name="file">
             <button type="submit">Save</button>
  </form>

Controller


  public function upload (Request$request)
    {
        $this->validate($request,[
            'file' = > 'required | image'
        ], [
            'file.required' = > 'No image selected',
            'file.image' = > 'Not an image file',
        ]);
        $file=$request->file('file');
        //dd($file);
        $list = Storage::disk('s3') - > files(');
        //dd($list);
        $path=Storage:::disk('s3') - > put('/', $file, 'public');
        //dd($path);
        return redirect("/");
    }

php laravel amazon-s3

2022-09-30 16:54

1 Answers

If an error occurs, it is recommended that you check the error content.I have never used Amazon S3, so I cannot give you a specific answer, but if you search Amazon s3put access denied first, you will find the following troubleshooting.

From Amazon S3 to 403: How to Troubleshoot Access Denied Errors

Also, if you're going to talk about it in general, it's okay to get it (see) with your own public access, but I think you'll need another permission to write a new file.Please check this area first.


2022-09-30 16:54

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.