安裝flysystem元件
composer require league/flysystem league/flysystem-aws-s3-v3
建立配置檔案https://github.com/donjan-deng/la-storage/...,這裡我們配置為支援Amazon S3協議的雲儲存,後面我們將搭建一個支援S3協議的私有云儲存。
return [
'default' => env('FILESYSTEM_DRIVER', 's3'),
'cloud' => env('FILESYSTEM_CLOUD', 's3'),
'disks' => [
's3' => [
'driver' => 's3',
'key' => env('AWS_KEY'),
'secret' => env('AWS_SECRET'),
'region' => env('AWS_REGION'),
'endpoint' => env('AWS_URL'),
'bucket' => env('AWS_BUCKET'),
'use_path_style_endpoint' => true
],
],
];
https://github.com/donjan-deng/la-storage/... 註冊配置
$app->configure('filesystems');
建立https://github.com/donjan-deng/la-storage/...返回驗證規則
在https://github.com/donjan-deng/la-storage/...寫上傳介面
並配置路由https://github.com/donjan-deng/la-storage/...
.env配置
FILESYSTEM_DRIVER=s3
AWS_KEY=ak
AWS_SECRET=sk
AWS_REGION=us-east-1
AWS_URL=url
AWS_BUCKET=image
部落格:《PHP 微服務練兵》系列教程
本作品採用《CC 協議》,轉載必須註明作者和本文連結