Php Laravel在我的项目的根目录中而不是s3中编写
我试图在laravel中建立到s3 bucket的连接,我正在测试连接,所以我制作了一个简单的函数,在“s3”存储中写入一个文件,但事实证明laravel实际上是在我的代码根本地写入文件!!我已经创建了一个s3 bucket,并创建了一个具有所需权限的Iam用户,我将机密放入.env文件中,但它不起作用,如果我尝试任何其他随机磁盘驱动程序,它会显示一个错误,如果我使用“本地”驱动程序,它工作正常(通过写入项目的存储目录)。但是,每当我尝试使用s3时,它都不会显示任何错误,而是写入项目根目录中 我在Php Laravel在我的项目的根目录中而不是s3中编写,php,laravel-5,Php,Laravel 5,我试图在laravel中建立到s3 bucket的连接,我正在测试连接,所以我制作了一个简单的函数,在“s3”存储中写入一个文件,但事实证明laravel实际上是在我的代码根本地写入文件!!我已经创建了一个s3 bucket,并创建了一个具有所需权限的Iam用户,我将机密放入.env文件中,但它不起作用,如果我尝试任何其他随机磁盘驱动程序,它会显示一个错误,如果我使用“本地”驱动程序,它工作正常(通过写入项目的存储目录)。但是,每当我尝试使用s3时,它都不会显示任何错误,而是写入项目根目录中 我
web.php
中的简单方法:
Route::get('/test',function(){
Storage::disk('s3')->put('hi.txt','hello');
return Storage::disk('s3')->get('hi.txt');
}))
filesystems.php:
<?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'),
'url' => env('AWS_URL','www.google.com'),
],
],
你安装了Amazon S3软件包吗?:league/flysystem-aws-S3-v3~1.0是的,我安装了。如果项目没有安装,Laravel会在项目上写吗?