xinningsu / baidu-bos
Baidu BOS client 百度对象存储API的基本调用
v1.0.1
2023-04-02 16:31 UTC
Requires
- php: >=5.6
- ext-json: *
- guzzlehttp/guzzle: >=6.0
Requires (Dev)
- php-coveralls/php-coveralls: ^2.1 || ^3.0
- phpunit/phpunit: >=5.0
- squizlabs/php_codesniffer: ^3.0
This package is auto-updated.
Last update: 2024-10-31 00:17:45 UTC
README
百度对象存储 BOS(Baidu Object Storage) API 针对指定bucket的一些基本操作。
安装
composer require xinningsu/baidu-bos
例子
require 'vendor/autoload.php'; // 实例化 $client = new \Sulao\BaiduBos\Client([ 'access_key' => 'access key', 'secret_key' => 'secret key', 'bucket' => 'bucket', 'region' => 'region', 'options' => ['connect_timeout' => 10] // Optional, guzzle request options ]); // 添加或更新对象 $client->putObject('/object_name.txt', 'contents'); // 获取对象内容 $content = $client->getObject('/object_name.txt'); // 获取对象Meta信息 $meta = $client->getObjectMeta('/object_name.txt'); // 复制对象 $client->copyObject('/object_name.txt', '/new_object_name.txt'); // 追加数据 $client->appendObject('/object_name.txt', 'more contents'); // URL抓取资源 $client->fetchObject('/object_name.txt', 'https://www.baidu.com'); // 设置ACL $client->putObjectAcl('/object_name.txt', 'public-read'); // 获取ACL $acl = $client->getObjectAcl('/object_name.txt'); // 删除ACL $client->deleteObjectAcl('/object_name.txt'); // 对象列表 $lists = $client->listObjects(); // 删除对象 $client->deleteObject('/object_name.txt'); // 批量删除对象 $client->deleteObjects(['/object_name.txt', '/object_name2.txt']);