PHP code example of muqiuren / hyperf-flysystem-upyun

1. Go to this page and download the library: Download muqiuren/hyperf-flysystem-upyun 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/ */

    

muqiuren / hyperf-flysystem-upyun example snippets


...
'storage' => [
    ...
    'upyun' => [
        'driver' => UpyunAdapterFactory::class,
        'username' => env('UPYUN_USERNAME'),
        'password' => env('UPYUN_PASSWORD'),
        'bucket_name' => env('UPYUN_BUCKET'),
        'options' => [
            UpyunHeaderEnum::CONTENT_SECRET->value => 'common_secret'
        ]
    ]
]

// 上传文件
public function putObject(\Hyperf\Filesystem\FilesystemFactory $factory)
{
    $storage = $factory->get('upyun');
    $path = '/test/hello.txt';
    $content = 'hello world';
    $storage->write($path, $content, [
        UpyunHeaderEnum::CONTENT_SECRET->value => 'custom_single_file_secret'
    ]);
}