Package Data | |
---|---|
Maintainer Username: | okashoi |
Maintainer Contact: | okashoicircus0@gmail.com (Okada Shohei) |
Package Create Date: | 2016-11-19 |
Package Last Update: | 2016-12-19 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2025-01-10 15:16:52 |
Package Statistics | |
---|---|
Total Downloads: | 148 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 4 |
Total Watchers: | 1 |
Total Forks: | 0 |
Total Open Issues: | 0 |
Laravel 5 Package to use Conoha Object Storage.
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
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.
Example
$objects = $handler->getList('container_name');
Example
$handler->upload('container_name', 'object_name.txt', '/path/to/file/to/upload.txt', 'text/plain');
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'));
Example
$handler->delete('container_name', 'object_name.txt');