我面临一个非常奇怪的情况,我期待着你的帮助.
我与Laravel建立了S3连接.另一项服务是将视频文件上传到我的亚马逊桶.这些文件由用户通过我的网站下载.
但是,这个系统很快就无法运行.文件上传到存储桶,但用户无法访问此文件.
我找了很长时间的问题来源,但我找不到它.后来,当我在我的锻造服务器上说“PHP artisan config:clear”时,系统又开始工作了.然后我想通过说“PHP artisan config:cache”来优化系统.但是,一切都恢复到原来的状态.所以它开始不起作用.
我使用联盟/ flysystem-aws-s3-v3包作为包.我正在努力解决这个问题,请帮忙吗?
return [
/*
|--------------------------------------------------------------------------
| Default Filesystem disk
|--------------------------------------------------------------------------
|
| Here you may specify the default filesystem disk that should be used
| by the framework. The "local" disk, as well as a variety of cloud
| based disks are available to your application. Just store away!
|
*/
'default' => env('FILESYstem_DRIVER', 'local'),
/*
|--------------------------------------------------------------------------
| Default Cloud Filesystem disk
|--------------------------------------------------------------------------
|
| Many applications store files both locally and in the cloud. For this
| reason, you may specify a default "cloud" driver here. This driver
| will be bound as the Cloud disk implementation in the container.
|
*/
'cloud' => env('FILESYstem_CLOUD', 's3'),
/*
|--------------------------------------------------------------------------
| Filesystem disks
|--------------------------------------------------------------------------
|
| Here you may configure as many filesystem "disks" as you wish, and you
| may even configure multiple disks of the same driver. Defaults have
| been setup for each driver as an example of the required options.
|
| Supported Drivers: "local", "ftp", "sftp", "s3", "rackspace"
|
*/
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
's3' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
],
],
];
它是我的.env文件.
AWS_ACCESS_KEY_ID="****"
AWS_SECRET_ACCESS_KEY="****"
AWS_DEFAULT_REGION="eu-west-3"
AWS_BUCKET="tokBox****"
我用这些线检查并下载了我的控制器中的文件;
$tokBoxapikey = env('OPENTOK_API_KEY');
$exist = Storage::disk('s3')->exists($tokBoxapikey . '/'. $archive_id.'/archive.mp4');
if($exist)
{
return Storage::disk('s3')->download($tokBoxapikey. '/'. $archive_id.'/archive.mp4');
}
解决方法:
更改
$tokBoxapikey = env('OPENTOK_API_KEY');
至
$tokBoxapikey = config('tokBox.api_key');