fhteam / selectel-storage-api
PHP Selectel 存储API
1.2
2015-06-17 10:18 UTC
Requires
- php: >=5.5.0
- guzzlehttp/guzzle: ~5.0
- league/url: ~3.0
Requires (Dev)
- phpmd/phpmd: *
- phpspec/phpspec: ~2.0
- phpunit/php-code-coverage: 2.0
- phpunit/phpunit: ~4.0
- squizlabs/php_codesniffer: ~2.0
This package is not auto-updated.
Last update: 2024-09-28 17:12:37 UTC
README
Selectel 云存储API。
Composer 配置
请注意,包名已更改为 fhteam/selectel-storage-api
。旧名称仍然可以使用,但将不再维护。
"require": {
"fhteam/selectel-storage-api": "dev-master"
}
认证
$config = include(__DIR__ . '/../data/config.php'); $container = new Container($config['auth_container']); $auth = new CredentialsAuthentication($config['auth_user'], $config['auth_key'], $config['auth_url']); $auth->authenticate();
上传文件
$file = new File('test.txt'); $file->setLocalName(__DIR__ . '/../data/config.php'); $file->setSize(); $service = new StorageService($auth); $service->uploadFile($container, $file);
删除文件
$file = new File('test.txt'); $service = new StorageService($auth); $service->deleteFile($container, $file);
并行操作
如果您需要在多个文件上执行操作,请考虑使用操作的并行版本。当使用操作的并行版本时,请求会同时发送到Selectel。执行会阻塞,直到从服务器接收到所有回复。
对于 uploadFile()
,有 uploadFiles()
,接受一个要上传到容器的文件数组。对于 deleteFile()
,也有 deleteFiles()
等等。
如果并行操作失败,则会引发 ParallelOperationException
,并带有可以检查的 $errors
字段。