PHP code example of liz / flysystem-aliyun
1. Go to this page and download the library: Download liz/flysystem-aliyun 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/ */
liz / flysystem-aliyun example snippets
use League\Flysystem\Filesystem;
use Liz\Flysystem\AliYun\AliYunOssAdapter;
$endpoint = 'oss-cn-beijing.aliyuncs.com';
$bucket = 'bucket';
$accessKey = 'access-key';
$secretKey = 'secret-key';
// write file
$result = $flysystem->write('bucket/path/file.txt', 'contents');
// write stream
$stream = fopen('.env', 'r+');
$result = $flysystem->writeStream('bucket/path/filestream.txt', $stream);
// update file
$result = $flysystem->update('bucket/path/file.txt', 'new contents');
// has file
$result = $flysystem->has('bucket/path/file.txt');
// read file
$result = $flysystem->read('bucket/path/file.txt');
// delete file
$result = $flysystem->delete('bucket/path/file.txt');
// rename files
$result = $flysystem->rename('bucket/path/filename.txt', 'bucket/path/newname.txt');
// copy files
$result = $flysystem->copy('bucket/path/file.txt', 'bucket/path/file_copy.txt');
// list the contents
$result = $flysystem->listContents('path', false);