【问题标题】:Laravel php artisan config:cache and AWS S3 access errorLaravel php artisan config:cache 和 AWS S3 访问错误
【发布时间】:2018-12-27 13:43:19
【问题描述】:

我面临一个非常奇怪的情况,我期待您的帮助。

我与 Laravel 建立了 S3 连接。另一个服务正在为我上传视频文件到我的亚马逊存储桶。这些文件是用户通过我的网站下载的。

但是,该系统不会很快运行。文件已上传到存储桶,但用户无法访问此文件。

找了好久问题的根源,还是没找到。后来,当我在我的 Forge 服务器上说“php artisan config: clear”时,系统又开始工作了。然后我想通过说“php artisan config:cache”来优化系统。但一切又回到了原来的状态。所以它开始不起作用。

我使用league/flysystem-aws-s3-v3 包作为包。我正在努力解决问题,请帮忙?

这是我的配置/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');
    }

【问题讨论】:

  • 你检查日志了吗?
  • 是的,我检查过没有奇怪的东西。 @OluwatobiSamuelOmisakin

标签: php laravel amazon-web-services laravel-5 amazon-s3


【解决方案1】:

改变

$tokboxapikey = env('OPENTOK_API_KEY');

$tokboxapikey = config('tokbox.api_key');

现在 laravel 将在 bootstrap/cache/config.php 中查找 $tokboxapikey。

【讨论】:

  • 非常感谢它运行顺利...非常感谢!!
猜你喜欢
  • 2019-04-13
  • 2018-02-16
  • 2021-01-13
  • 2015-05-11
  • 2017-03-20
  • 2017-12-22
  • 2016-01-29
  • 2016-05-14
  • 2015-09-22
相关资源
最近更新 更多