sakuara-bj/laravel-filesystem-obs

Laravel 的 OBS 存储文件系统

1.0.0 2023-11-15 02:22 UTC

This package is auto-updated.

Last update: 2024-09-15 04:05:38 UTC


README

华为云 OBS 存储基于 bjphp/laravel-filesystem-obs 的 Laravel。文件私有下载 URL

要求

  • PHP >= 7.3.1

安装

$ composer require "sakuara-bj/laravel-filesystem-obs" -vvv

使用

use Obs\ObsClient;
use Shopex\Obs\ObsAdapter;
use League\Flysystem\Filesystem;

$conf['key'] = 'xxx';
$conf['secret'] = 'xxx';
$conf['endpoint'] = 'xxx';
$conf['region'] = 'xxx';

$client = new ObsClient($config);

$debug = $config['debug'] ?? false;
$endpoint = $config['endpoint'] ?? '';
$cdn_domain = $config['cdn_domain'] ?? '';
$ssl_verify = $config['ssl_verify'] ?? false;

$filesystem = new Filesystem(new ObsAdapter($client, $bucket, $endpoint, $cdn_domain, $ssl_verify));

API

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

bool $flysystem->write('file.md', 'http://httpbin.org/robots.txt', ['mime' => 'application/redirect302']);

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

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

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

bool $flysystem->rename('foo.md', 'bar.md');

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->getAdapter()->getUrl('file.md'); 

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

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

插件

文件 URL

use Shopex\Obs\Plugins\CreatePostSignature;

$flysystem->addPlugin(new CreatePostSignature());

array $flysystem->createPostSignature([
    'Bucket' => $bucket,
    'Key' => $key,
    'Expires' => 3600,
])->toArray();

许可

MIT