项目作者: xxtime

项目描述 :
FlySystem For AliYun OSS
高级语言: PHP
项目地址: git://github.com/xxtime/flysystem-aliyun-oss.git
创建时间: 2017-07-06T09:32:30Z
项目社区:https://github.com/xxtime/flysystem-aliyun-oss

开源协议:

下载


Aliyun OSS Adapter For Flysystem.

Latest Stable Version
Build Status
Total Downloads
License
Author
Code Climate

AliYun OSS Storage adapter for flysystem - a PHP filesystem abstraction.

Installation

composer require xxtime/flysystem-aliyun-oss

Logs

1.3.0
  1. some args name changed
  2. default region oss-cn-hangzhou
    1.7.0
    1. support flysystem v3
    2. support oss-sdk-php 2.6
    3. support PHP8

Usage

  1. use League\Flysystem\Filesystem;
  2. use Xxtime\Flysystem\Aliyun\OssAdapter;
  3. $aliyun = new OssAdapter([
  4. 'accessId' => '<aliyun access id>',
  5. 'accessSecret' => '<aliyun access secret>',
  6. 'bucket' => '<bucket name>',
  7. 'endpoint' => '<endpoint address>',
  8. // 'timeout' => 3600,
  9. // 'connectTimeout' => 10,
  10. // 'isCName' => false,
  11. // 'token' => '',
  12. ]);
  13. $filesystem = new Filesystem($aliyun);
  14. // Write Files
  15. $filesystem->write('path/to/file.txt', 'contents');
  16. // get RAW data from aliYun OSS
  17. $raw = $aliyun->supports->getFlashData();
  18. // Write Use writeStream
  19. $stream = fopen('local/path/to/file.txt', 'r+');
  20. $filesystem->writeStream('path/to/file.txt', $stream);
  21. // Update Files
  22. $filesystem->update('path/to/file.txt', 'new contents');
  23. // Check if a file exists
  24. $exists = $filesystem->has('path/to/file.txt');
  25. // Read Files
  26. $contents = $filesystem->read('path/to/file.txt');
  27. // Delete Files
  28. $filesystem->delete('path/to/file.txt');
  29. // Rename Files
  30. $filesystem->rename('filename.txt', 'newname.txt');
  31. // Copy Files
  32. $filesystem->copy('filename.txt', 'duplicate.txt');
  33. // list the contents (not support recursive now)
  34. $filesystem->listContents('path', false);
  1. // 说明:此方法返回从阿里云接口返回的原生数据,仅可调用一次
  2. // DESC: this function return AliYun RAW data
  3. $raw = $aliyun->supports->getFlashData();

Document

  1. Region And Endpoint Table
  2. Aliyun OSS PHP SDK Document

Reference

http://flysystem.thephpleague.com/api/
https://github.com/thephpleague/flysystem