PHP code example of gumphp / think-filesystem

1. Go to this page and download the library: Download gumphp/think-filesystem library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

gumphp / think-filesystem example snippets


# config/filesystem.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' => '/',
        ],
    ],
];


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'));
    }
}