PHP code example of zing / flysystem-tos

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

    

zing / flysystem-tos example snippets


use League\Flysystem\Filesystem;
use Tos\TosClient;
use Zing\Flysystem\Tos\TosAdapter;

$prefix = '';
$config = [
    'ak' => 'aW52YWxpZC1rZXk=',
    'sk' => 'aW52YWxpZC1zZWNyZXQ=',
    'region' => 'cn-shanghai',
    'bucket' => 'test',
    'endpoint' => 'tos-cn-shanghai.volces.com',
];

$config['options'] = [
    'url' => '',
    'endpoint' => $config['endpoint'], 
    'bucket_endpoint' => '',
    'temporary_url' => '',
];

$client = new TosClient($config);
$adapter = new TosAdapter($client, $config['bucket'], $prefix, null, null, $config['options']);
$flysystem = new Filesystem($adapter);