首页 > 解决方案 > Laravel,AWS S3“拒绝访问”私有访问

问题描述

我创建了一个 S3 存储桶并可以上传到它。只要我的 S3 存储桶完全公开,我就可以在 Laravel 中以编程方式查看上传。将其设为私有后,我会收到“拒绝访问”错误。我创建了一个用户,赋予该用户 AmazonS3FullAccess 权限并将 AWS_ACCESS_KEY_ID 和 AWS_SECRET_ACCESS_KEY 包含到 .env 中。我遵循了本指南:https ://dev.to/aschmelyun/getting-started-with-amazon-s3-storage-in-laravel-5b6d 。有任何想法吗?

标签: laravelamazon-s3

解决方案


Does it still store accordingly or is it when trying to view that you get the error ? Have you taken a look at https://laravel.com/docs/8.x/filesystem#file-urls

You should be using something like

Storage::url($customer->file-path-name);

By the way try avoiding hyphen separated name. Either go camelCase or snake_case ... hyphen are typically reserved for file names(the actual file, not the reference in your DB)


推荐阅读