我面临一个非常奇怪的情况,期待您的帮助。
我与Laravel建立了S3连接,另一个服务是将视频文件上传到我的亚马逊存储桶中。这些文件是用户通过我的网站下载的。
但是,此系统很快将无法使用。这些文件已上传到存储桶,但用户无法访问此文件。
我一直在寻找问题的根源,但找不到。后来,当我在伪造服务器上说“ php artisan config:clear”时,系统再次开始工作。然后,我想通过说“ php artisan config:cache”来优化系统。但是,一切又回到了原始状态。因此它开始不起作用。
我使用League / flysystem-aws-s3-v3软件包作为软件包。我正在尝试解决问题,请帮忙?
这是我的config / filesystem.php
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');
}
答案 0 :(得分:2)
更改
$tokboxapikey = env('OPENTOK_API_KEY');
到
$tokboxapikey = config('tokbox.api_key');
现在laravel将寻找$ tokboxapikey的bootstrap / cache / config.php。