WArk-MinioStorage
, (*1)
Minio oss filesystem storage for laravel 5+, (*2)
Minio Server
You can download the minio oss server from here., (*3)
Minio is an object storage server. Size of an object can range from a few KBs to a maximum of 5TB.
It is best suited for storing unstructured data such as photos, videos, log files, backups
and container / VM images.
Minio server is light enough to be bundled with the application stack, similar to NodeJS, Redis and MySQL.
Installation
Open the command prompt and type in the following. This will download the package.
composer require wark/miniostorage
After that, add the ServiceProvider to the providers array in config/app.php
WArk\Minio\Providers\MinioStorageServiceProvider::class,
You can use the facade for shorter code. Add this to your aliases:
'MinioStorage' => WArk\Minio\Facades\MinioStorage::class,
To publish the config settings in Laravel 5 use:
php artisan vendor:publish
This will add an miniostorage.php config file to your config folder., (*4)
Set Environment Variable in .env file
MINIO_ACCESS_KEY=<access_key>
MINIO_ACCESS_SECRET=<access_secret>
MINIO_ACCESS_REGION=null
MINIO_BUCKET_NAME=<bucket>
MINIO_ACCESS_ENDPOINT=http://localhost:9000
Usage
Use it like below:, (*5)
Save Image/Video/Object
MinioStorage::store('key/key', Input::file('file'));
Use Input::file('file') to get the uploaded file and put it directly. key/key can be any string., (*6)
$data = file_get_contents('data');
MinioStorage::store('key/key', $data, true);
Use the third argument as true to upload the raw data as object., (*7)
Retrieve Image/Video/Object
MinioStorage::get('key/key');
Get the object by key string., (*8)
MinioStorage::getWithBucket('bucket', 'key/key');
Specify the bucket and get the object from the bucket., (*9)
List out the objects
MinioStorage::listObjects();
List out the objects with specified bucket
MinioStorage::listObjectsWithBucket();
Specify the bucket and list out the object from the bucket., (*10)
Remove Object
MinioStorage::removeObject('key');
Delete the specified object, (*11)
Remove Object with specified bucket
MinioStorage::removeObjectWithBucket('bucket','key');
Delete the specified object with specified bucket, (*12)
Check Bucket Exist
MinioStorage::checkBucketExist('bucketName');
Check if the bucket exist or not. Return true if exist and false otherwise., (*13)
Create Bucket If Not Exist
MinioStorage::createBucketIfNotExist('bucketName');
Create the bucket if the bucket does not exist., (*14)
Create Bucket
MinioStorage::createBucket('bucketName');
Create new bucket, (*15)
Create Bucket Async
MinioStorage::createBucketAsync('bucketName');
Create new bucket asynchronously, (*16)
Remove Bucket
MinioStorage::removeBucket('bucketName');
Delete the specified bucket, (*17)
Remove Bucket Async
MinioStorage::removeBucketAsync('bucketName');
Delete the specified bucket asynchronously, (*18)
Copy Object
MinioStorage::copyObject('key', 'toBucketName', 'toKey');
Copy existing object from to another bucket with new key name, (*19)
Copy Object From
MinioStorage::copyObjectFrom('fromBucketName', 'key', 'toBucketName', 'toKey');
Copy object from specified bucket to another bucket with new key name, (*20)
License
The MIT License (MIT). Please see License File for more information., (*21)