It's possible that Amazon has updated their S3 storage settings, but it's also possible that there's an issue with your code or configuration. Here are a few things you can try:
-
Double-check that you've unchecked the "Block public access" setting for your S3 bucket. This is necessary to allow public access to your files.
-
Make sure that you're setting the correct ACL (Access Control List) when uploading your files. The ACL determines who has access to the file. To upload a file with public access, you should set the ACL to "public-read". Here's an example:
Storage::disk('s3')->put('filename.txt', $contents, 'public');
- If setting the ACL doesn't work, try setting the "visibility" option to "public" when configuring your S3 disk in Laravel. Here's an example:
's3' => [
'driver' => 's3',
'key' => 'your-key',
'secret' => 'your-secret',
'region' => 'your-region',
'bucket' => 'your-bucket',
'visibility' => 'public',
],
- If none of the above solutions work, try using the AWS SDK directly to upload your files. Here's an example:
use Aws\S3\S3Client;
$client = new S3Client([
'version' => 'latest',
'region' => 'your-region',
'credentials' => [
'key' => 'your-key',
'secret' => 'your-secret',
],
]);
$result = $client->putObject([
'Bucket' => 'your-bucket',
'Key' => 'filename.txt',
'Body' => $contents,
'ACL' => 'public-read',
]);
if ($result['@metadata']['statusCode'] === 200) {
// File uploaded successfully
} else {
// Error uploading file
}
Hopefully one of these solutions will work for you!