liz/flysystem-aliyun

阿里云 OSS 适配器 for flysystem

v1.2 2019-01-11 08:19 UTC

This package is auto-updated.

Last update: 2024-09-12 05:23:30 UTC


README

Software License

Flysystem 适配器: 阿里云

安装

composer require liz/flysystem-aliyun

使用

require 'vendor/autoload.php';


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

注意

由于阿里云没有文件夹的概念,建议顶级目录与 bucket 名一致 getVisibility()setVisibility() 在阿里云中未提供相关操作