okashoi/laravel5-conoha-object-handler
Composer 安装命令:
composer require okashoi/laravel5-conoha-object-handler
包简介
An object handler for the Conoha Object Storage on Laravel 5.
关键字:
README 文档
README
Laravel 5 Package to use Conoha Object Storage.
Installation
Install the package via Composer.
composer require okashoi/laravel5-conoha-object-handler
To use the package, register the service provider in config/app.php.
'providers' => [ // ... Okashoi\Laravel5ConohaObjectHandler\ConohaObjectServiceProvider::class, ]
To configure your connection settings, execute the following command.
php artisan vendor:publish --provider="Okashoi\Laravel5ConohaObjectHandler\ConohaObjectServiceProvider"
Then set the following environment variables in .env file.
CONOHA_TENANT_ID
CONOHA_USERNAME
CONOHA_PASSWORD
Usage
Create the Instance
First of all you have to create an ObjectHandler instance.
use Okashoi\Laravel5ConohaObjectHandler\ObjectHandler; $handler = new ObjectHandler();
Optionally, you can cache the auth token by specifying the cache key. (It is recommended. By default, the instance gets a new auth token per a request.)
use Okashoi\Laravel5ConohaObjectHandler\ObjectHandler; // cache the auth token with key 'conoha_token' $handler = new ObjectHandler('conoha_token');
Caching is implemented using Laravel Cache API.
Get a List of Objects
Example
$objects = $handler->getList('container_name');
Upload an Object
Example
$handler->upload('container_name', 'object_name.txt', '/path/to/file/to/upload.txt', 'text/plain');
Download an Object
The method download() will return GuzzleHttp response.
You can access the file content by getBody() method.
$response = $handler->download('container_name', 'object_name.txt'); echo $response->getBody();
Or you can make download response as follows.
$response = $handler->download('container_name', 'object_name.txt'); return reponse($response->getBody())->header('Content-Type', $response->getHeader('Content-Type'));
Delete an Object
Example
$handler->delete('container_name', 'object_name.txt');
统计信息
- 总下载量: 149
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-11-19