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:
The .env access key and the secret access key are correct, so I don't think that's relevant.
By the way, you can retrieve images from the bucket as follows:
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("/");
}
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.
© 2024 OneMinuteCode. All rights reserved.