forumhouseteam / selectel-storage-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: 2019-02-20 18:17:30 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
字段。