Open coolgauravjain90 opened 4 months ago
Finally managed to make it work
You can follow this tutorial but you will have to make some changes in your Provider
As mentionned in the Official Laravel Documentation you need to update the implementation
Here's my working implementation with :
league/flysystem-aws-s3-v3 "^3.0"
(be sure to composer require league/flysystem-aws-s3-v3 "^3.0" --with-all-dependencies
)<?php
namespace App\Providers;
use Illuminate\Filesystem\FilesystemAdapter;
use Illuminate\Support\ServiceProvider;
use Aws\S3\S3Client;
use League\Flysystem\AwsS3V3\AwsS3V3Adapter;
use League\Flysystem\Filesystem;
use Illuminate\Support\Facades\Storage;
class OciObjectStorageServiceProvider extends ServiceProvider
{
/**
* Register services.
*/
public function register(): void
{
//
}
public function boot()
{
if (config('filesystems.default') !== 'oci') {
return;
}
Storage::extend('s3', function($app, $config) {
$myConfig = [
'credentials' => [
'key' => $config['key'],
'secret' => $config['secret'],
],
'region' => $config['region'],
'version' => '2006-03-01',
'use_path_style_endpoint' => true, // Set to true if you are using an S3 clone
'bucket_endpoint' => true,
'endpoint' => $config['url']
];
$client = new S3Client($myConfig);
$adapter = new AwsS3V3Adapter($client, $config['bucket']);
return new FilesystemAdapter(
new Filesystem($adapter, $config),
$adapter,
$myConfig
);
});
}
}
You can give such a try in one of your controller (for the sake of the test) :
Storage::disk('oci')->put('test.txt', 'Hello World');
Enjoy :rocket:
Finally managed to make it work
You can follow this tutorial but you will have to make some changes in your Provider
As mentionned in the Official Laravel Documentation you need to update the implementation
Here's my working implementation with :
- Php 8.3
- Laravel 11
league/flysystem-aws-s3-v3 "^3.0"
(be sure tocomposer require league/flysystem-aws-s3-v3 "^3.0" --with-all-dependencies
)<?php namespace App\Providers; use Illuminate\Filesystem\FilesystemAdapter; use Illuminate\Support\ServiceProvider; use Aws\S3\S3Client; use League\Flysystem\AwsS3V3\AwsS3V3Adapter; use League\Flysystem\Filesystem; use Illuminate\Support\Facades\Storage; class OciObjectStorageServiceProvider extends ServiceProvider { /** * Register services. */ public function register(): void { // } public function boot() { if (config('filesystems.default') !== 'oci') { return; } Storage::extend('s3', function($app, $config) { $myConfig = [ 'credentials' => [ 'key' => $config['key'], 'secret' => $config['secret'], ], 'region' => $config['region'], 'version' => '2006-03-01', 'use_path_style_endpoint' => true, // Set to true if you are using an S3 clone 'bucket_endpoint' => true, 'endpoint' => $config['url'] ]; $client = new S3Client($myConfig); $adapter = new AwsS3V3Adapter($client, $config['bucket']); return new FilesystemAdapter( new Filesystem($adapter, $config), $adapter, $myConfig ); }); } }
You can give such a try in one of your controller (for the sake of the test) :
Storage::disk('oci')->put('test.txt', 'Hello World');
Enjoy 🚀
Hello,
Can you show me how is your config OCI file in filesystem.php?
how u set the URL parm?
any way i used has problems..
@olivier1208 Hello,
Can you show me how is your config OCI file in filesystem.php?
how u set the URL parm?
any way i used has problems..
@olivier1208 Hello,
Can you show me how is your config OCI file in filesystem.php?
how u set the URL parm?
any way i used has problems..
As simple as that :
'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'),
],
Asssumed you have this in your .env
:
FILESYSTEM_DISK=oci
OCI_ACCESS_KEY_ID=yout_access_key
OCI_SECRET_ACCESS_KEY=your_secret_key
OCI_DEFAULT_REGION=your_region
OCI_BUCKET=your_bucket
OCI_URL=https://your_namespace.compat.objectstorage.your_region.oraclecloud.com
OCI_USE_PATH_STYLE_ENDPOINT=false
Bug Report
Summary
How to reproduce
Unable to integrate OCI in laravel 10 with this flysystem.