PHP code example of yzh52521 / flysystem-upyun

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

    

yzh52521 / flysystem-upyun example snippets



use League\Flysystem\Filesystem;
use yzh52521\Flysystem\Upyun\UpyunAdapter;

$bucket = 'your-bucket-name';
$operator = 'oparator-name';
$password = 'operator-password';
$domain = 'xxxxx.b0.upaiyun.com'; // 或者 https://xxxx.b0.upaiyun.com
$protocol='https', // 服务使用的协议,如需使用 http,在此配置 http

$adapter = new UpyunAdapter($bucket, $operator, $password, $domain,$protocol);

$flysystem = new Filesystem($adapter);



bool $flysystem->write('file.md', 'contents');

bool $flysystem->writeStream('file.md', fopen('path/to/your/local/file.jpg', 'r'));

bool $flysystem->copy('foo.md', 'foo2.md');

bool $flysystem->delete('file.md');

bool $flysystem->has('file.md');

string|false $flysystem->read('file.md');

array $flysystem->listContents();

array $flysystem->getMetadata('file.md');

int $flysystem->getSize('file.md');

string $flysystem->getUrl('file.md'); 

string $flysystem->getMimetype('file.md');