Giter VIP home page Giter VIP logo

laravel-oci-object-storage's Introduction

Custom Laravel FileSystem for Oracle Object Storage

Clone this repository or create your fresh Laravel project

Add the following keys in your .env file

FILESYSTEM_DRIVER=oci  
OCI_ACCESS_KEY_ID=  
OCI_SECRET_ACCESS_KEY=  
OCI_DEFAULT_REGION=  
OCI_BUCKET=  
OCI_URL=

Get the values from your Oracle console.

Note the the URL format should be as follow

https://{{Namespace}}.compat.objectstorage.{{region}}.oraclecloud.com

Get the Namespace from your bucket details or from your user page from the console

Then update config/filesystems.php, add the following values

'disks' => [
	...
    'oci' => [
        'driver' => 's3',
        'key' => env('OCI_ACCESS_KEY_ID'),
        'secret' => env('OCI_SECRET_ACCESS_KEY'),
        'region' => env('OCI_DEFAULT_REGION'),
        'bucket' => env('OCI_BUCKET'),
        'url' => env('OCI_URL') .  '/'.  env('OCI_BUCKET'),
    ],
]

Then run the following command your project to create the provider

php artisan make:provider OciObjectStorageServiceProvider

Then update the created file as follow

use Aws\S3\S3Client;
use League\Flysystem\AwsS3v3\AwsS3Adapter;
use League\Flysystem\Filesystem;
use Storage;
...
public  function  boot()
{
    if (config('filesystems.default') != 'oci') {
	    return;
    }

    Storage::extend('s3', function($app, $config) {
	    $client = new  S3Client([
		    'credentials' => [
			    'key' => $config['key'],
			    'secret' => $config['secret'],
		    ],
		    'region' => $config['region'],
		    'version' => '2006-03-01',
		    'bucket_endpoint' => true,
		    'endpoint' => $config['url']
	    ]);

	    return  new  Filesystem(new  AwsS3Adapter($client, $config['bucket'], $config['bucket']));
    });
}

Then finally just add the newly created provider in config/app.php

'providers' => [
    ...
    App\Providers\OciObjectStorageServiceProvider::class,
    ...
],

I hope it was clear.

Happy Coding...

laravel-oci-object-storage's People

Contributors

hassanoumar avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.