此文章同步刊登於我的部落格
Simple Storage Service (S3) 是 AWS 最常應用到的服務,只要是需要將檔案上傳到雲端的狀況都可以使用S3,本篇文章將介紹如何設定與使用AWS S3。
https://laravel-news.com/using-s3-with-laravel
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1420044805001",
"Effect": "Allow",
"Action": [
"s3:ListBucket",
"s3:GetObject",
"s3:GetObjectAcl",
"s3:PutObject",
"s3:PutObjectAcl",
"s3:ReplicateObject",
"s3:DeleteObject"
],
"Resource": [
"arn:aws:s3:::your-bucket-name",
"arn:aws:s3:::your-bucket-name/*"
]
}
]
}
Statement.Resource
的內容,將名稱改為剛剛建立的儲存體名稱後點選「檢閱政策」php artisan vendor:publish --provider="Spatie\MediaLibrary\MediaLibraryServiceProvider" --tag="migrations"
php artisan migration
php artisan db:seed --class=MediaTempSeeder
php artisan vendor:publish --provider="Spatie\MediaLibrary\MediaLibraryServiceProvider" --tag="config"
AWS_ACCESS_KEY_ID=<public key>
AWS_SECRET_ACCESS_KEY=<private key>
AWS_DEFAULT_REGION=<儲存體伺服器>
AWS_BUCKET=<儲存體名稱>
AWS_USE_PATH_STYLE_ENDPOINT=true
MEDIA_DISK=medialibrary
MEDIA_LIBRARY_ROOT=media_development
MEDIA_DISK=public
php artisan storage:link