phico/cdn

Phico的轻量级CDN支持

dev-main 2024-08-04 18:47 UTC

This package is auto-updated.

Last update: 2024-09-06 11:56:14 UTC


README

Phico的轻量级CDN支持Phico

安装

使用composer

composer require phico/cdn

使用方法

CDN提供快速简单的访问AWS S3和Cloudflare R2私有CDN。

对象

// put a local file on the cdn
$cdn->put('path/to/local/file.txt', '/path/on/cdn/file.txt');

// retrieve the file content
$content = $this->cdn->get('/path/on/cdn/file.txt');

// delete the file
$cdn->delete('/path/on/cdn/file.txt');

切换存储桶

如果您已连接并具有必要的权限,您可以切换存储桶。

$cdn->bucket('other-bucket')->put('local/file.txt', 'uploads/file.txt');
$cdn->bucket('backup-bucket')->put('local/file.txt', 'uploads/file.txt');

存储桶

如果您已连接并具有必要的权限,您可以管理存储桶。

// list all buckets
$array = $cdn->buckets();

// create a bucket on the cdn
$cdn->bucket('tmp')->create();

// list objects in the bucket
$array = $cdn->bucket('tmp')->list();

// switching a bucket will be remembered so the above two lines could be shortened to
$array = $cdn->bucket('tmp')->create()->list();

// delete the bucket from the cdn
$cdn->bucket('tmp')->delete();

问题

如果您发现任何与行为或性能相关的错误或问题,请创建一个问题,如果可能,请提交一个包含修复的pull request。

请确保根据需要更新测试。

对于重大更改,请首先打开一个问题来讨论您想要更改的内容。

许可证

BSD-3-Clause