7graus/bunnycdn-storage

从用于与BunnyCDN存储API交互的官方PHP库派生。

dev-master 2020-07-13 16:06 UTC

This package is auto-updated.

Last update: 2024-09-14 01:45:40 UTC


README

用于与BunnyCDN存储API交互的官方PHP库。

如何安装

composer require 7graus/bunnycdn-storage:dev-master

如何使用

存储库非常简单易用。首先,使用认证详情创建基本的BunnyCDNStorage对象。这是与API交互的基本对象。

$bunnyCDNStorage = new BunnyCDNStorage("storagezonename", "MyAccessKey", "sg");

BunnyCDNStorage构造函数接受以下参数

  • storageZoneName - 您的存储区域名称
  • apiAccessKey - API访问密钥(密码)
  • storageZoneRegion - 存储区域区域代码(de、ny或sg)

导航


上传对象

要将文件上传到存储,您可以使用uploadFile方法。如果对象的路径尚不存在,它将被自动创建。

$bunnyCDNStorage->uploadFile("local/file/path/helloworld.txt", "/storagezonename/helloworld.txt");

列出对象

获取给定路径上所有对象的列表。

$bunnyCDNStorage->getStorageObjects("/storagezonename/");

StorageObject包含以下属性

  • Guid - 文件的唯一GUID
  • UserId - 持有文件的BunnyCDN用户ID
  • DateCreated - 文件创建的日期
  • LastChanged - 文件最后修改的日期
  • StorageZoneName - 与文件关联的存储区域名称
  • Path - 对象的路径
  • ObjectName - 对象的名称
  • Length - 对象的总字节数
  • IsDirectory - 如果对象是目录则为真,否则为假。
  • ServerId - 文件所在存储服务器的ID
  • StorageZoneId - 与对象关联的存储区域ID
  • FullPath - 文件的全路径

下载对象

要从存储中将对象下载到本地文件,您可以使用downloadFile方法。

$bunnyCDNStorage->downloadFile("/storagezonename/helloworld.txt", "local/file/path/helloworld.txt");

删除对象

删除支持文件和目录。如果目标对象是目录,目录内容也将被删除。

$bunnyCDNStorage->deleteObject("/storagezonename/helloworld.txt");