Minio oss filesystem storage for laravel 5+
You can download the minio oss server from here.
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.
####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:publishThis will add an miniostorage.php config file to your config folder.
####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: ####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/keycan be any string.
$data = file_get_contents('data');
MinioStorage::store('key/key', $data, true);Use the third argument as
trueto upload the raw data as object.
####Retrieve Image/Video/Object
MinioStorage::get('key/key');Get the object by key string.
MinioStorage::getWithBucket('bucket', 'key/key');Specify the bucket and get the object from the bucket.
####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.
####Remove Object
MinioStorage::removeObject('key');Delete the specified object
####Remove Object with specified bucket
MinioStorage::removeObjectWithBucket('bucket','key');Delete the specified object with specified bucket
####Check Bucket Exist
MinioStorage::checkBucketExist('bucketName');Check if the bucket exist or not. Return true if exist and false otherwise.
####Create Bucket If Not Exist
MinioStorage::createBucketIfNotExist('bucketName');Create the bucket if the bucket does not exist.
####Create Bucket
MinioStorage::createBucket('bucketName');Create new bucket
####Create Bucket Async
MinioStorage::createBucketAsync('bucketName');Create new bucket asynchronously
####Remove Bucket
MinioStorage::removeBucket('bucketName');Delete the specified bucket
####Remove Bucket Async
MinioStorage::removeBucketAsync('bucketName');Delete the specified bucket asynchronously
####Copy Object
MinioStorage::copyObject('key', 'toBucketName', 'toKey');Copy existing object from to another bucket with new key name
####Copy Object From
MinioStorage::copyObjectFrom('fromBucketName', 'key', 'toBucketName', 'toKey');Copy object from specified bucket to another bucket with new key name
The MIT License (MIT). Please see License File for more information.