laravel - 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 。有任何想法吗?
解决方案
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)
推荐阅读
- bash - 从通过 xargs 启动的多个进程写入同一个 fifo 管道会导致行丢失
- bash - 如何使用bash删除s3中的多个文件?
- python - 将两列中的数据保存到两个列表中
- arrays - 如何将我的 pfx 文件转换为 byte[] 以用于 API 管理?
- node.js - Node.js 暴力预防
- python - 通过批处理运行 Python,不同的 Python.exe 爱好?
- r - 在 R 中执行具有挑战性的水平点图,显示 Min、Max、Mean 和 StD 值
- javascript - 提交带有附件的表单还是 JS 和 HTML 格式?
- javascript - Javascript 创建 iFrame dom innerHTML
- amazon-web-services - AWS API Gateway Swagger 导出不导出模型