微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Laravel php artisan config:缓存和AWS S3访问错误

我面临一个非常奇怪的情况,我期待着你的帮助.

我与Laravel建立了S3连接.另一项服务是将视频文件上传到我的亚马逊桶.这些文件用户通过我的网站下载.

但是,这个系统很快就无法运行.文件上传到存储桶,但用户无法访问此文件.

我找了很长时间的问题来源,但我找不到它.后来,当我在我的锻造服务器上说“PHP artisan config:clear”时,系统又开始工作了.然后我想通过说“PHP artisan config:cache”来优化系统.但是,一切都恢复到原来的状态.所以它开始不起作用.

我使用联盟/ 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');
    }

解决方法:

更改

$tokBoxapikey = env('OPENTOK_API_KEY');

$tokBoxapikey = config('tokBox.api_key');

现在,laravel将为$tokBoxapikey寻找bootstrap / cache / config.PHP.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐