定制 bunnycdn/storage 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

bunnycdn/storage

最新稳定版本:3.4.0

Composer 安装命令:

composer require bunnycdn/storage

包简介

PHP library to interact with the BunnyCDN Storage API.

README 文档

README

The official PHP library used for interacting with the BunnyCDN Storage API.

Install

composer require bunnycdn/storage

Usage

Create an instance of the \Bunny\Storage\Client with the authentication details

$client = new \Bunny\Storage\Client('access-key', 'storage-zone', \Bunny\Storage\Region::SINGAPORE);

The BunnyCDNStorage constructor takes the following parameters:

  • apiAccessKey - The API access key (password)
  • storageZoneName - The name of your storage zone
  • storageZoneRegion - The storage zone region code (de, ny, or sg)

Navigation:

Uploading objects

$client->upload('/path/to/local/file.txt', 'remote/path/hello-world.txt');

The checksum can be disabled using the $withChecksum parameter:

$client->upload('/path/to/local/file.txt', 'remote/path/hello-world.txt', false);

Note

Async uploads are supported with $client->uploadAsync(). It will return a GuzzleHttp\Promise\PromiseInterface.

Downloading objects

$client->download('remote/path/hello-world.txt', '/path/to/local/file.txt');

Listing objects

$items = $client->listFiles('remote/path/');

Returns an array of FileInfo objects.

Get an object's details

$item = $client->info('remote/path/hello-world.txt');

Returns an instance of FileInfo.

Deleting objects

$client->delete('remote/path/hello-world.txt');

Delete multiple objects

$errors = $client->deleteMultiple(['file1.txt', 'file2.txt', 'non-existing.txt']);
var_dump($errors);

/*
array(1) {
  'non-existing.txt' =>
  string(16) "Object not found"
}
*/

Put file contents

$content = 'Hello, world!';
$client->putContents('hello-world.txt', $content);

The checksum can be disabled using the $withChecksum parameter:

$content = 'Hello, world!';
$client->putContents('hello-world.txt', $content, false);

Get file contents

$content = $client->getContents('hello-world.txt');
echo $content; // Hello, world!

统计信息

  • 总下载量: 47.21k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 83
  • 点击次数: 1
  • 依赖项目数: 3
  • 推荐数: 1

GitHub 信息

  • Stars: 82
  • Watchers: 9
  • Forks: 29
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-12-14