我正在尝试使用 Filesystem ,用 Laravel 5.1 实现 league/flysystem-aws-s3-v3。但我可以从 S3 获取文件。
所以,我编码如下:
$s3 = Storage::disk('s3');
$imageName = Employee::filePath() . $employee->id . '.pdf';
if (Storage::disk('s3')->exists($imageName)) {
return response()->download(Storage::disk('s3')->get($imageName));
}
然后我收到以下错误:
CredentialsException in InstanceProfileProvider.php line 79: Error retrieving credentials from the instance profile metadata server. (cURL error 28: Connection timed out after 1001 milliseconds (see http://curl.haxx.se/libcurl/c/libcurl-errors.html))
凭据在 config/filesystems.php 上设置,我知道很好,因为我可以将文件放在那里。
你有什么想法吗?
提前致谢。
最佳答案
问题出在我的配置上,我尝试使用 env 进行设置,但是由于某种原因在配置时没有加载,所以我决定直接放在配置文件 filesystems.php 上
's3' => [
'driver' => 's3',
'key' => 'XXXXXXXXXX',
'secret' => 'XXXXXXXXXX',
'region' => env('S3_REGION'),
'bucket' => env('S3_BUCKET'),
],
关于php - Laravel 存储文件系统和 Amazon S3 出现 CredentialsException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46512904/