gumphp/think-filesystem

v1.0.2 2023-06-01 07:49 UTC

This package is auto-updated.

Last update: 2024-04-30 01:04:11 UTC


README

composer require gumphp/think-filesystem:dev-master

配置

# config/filesystem.php
<?php
return [
    // 默认磁盘
    'default' => env('filesystem.driver', 'aws'),
    // 磁盘列表
    'disks' => [
        // 更多的磁盘配置信息
        'aws'  => [
            'type' => 'aws',
            'credentials' => [
                'key' => env('AWS.S3_KEY', ''),
                'secret' => env('AWS.S3_SECRET', ''),
            ],
            'version' => env('AWS.S3_VERSION', 'latest'),
            'region' => env('AWS.S3_REGION', 'us-west-2'),
            'bucket' => env('AWS.S3_BUCKET', ''),
            'prefix' => '/',
        ],
    ],
];

使用

<?php
namespace app\controller;

use think\facade\Filesystem;

class Index
{
    public function index()
    {
        Filesystem::disk('aws')->put('/s3/remote/file.ext', file_get_contents('/path/yourfile.ext'));
    }
}