Wasabi is a cloud object storage that is compatible with Amazon S3. It can be integrated with AWS, Google Cloud or Microsoft Azure solutions, using the same protocol and tools. Wasabi is a value-oriented, high-performance, low-latency, and high-availability cloud object storage offering.
Step - 1: Set up your laravel app enviroment (.env file) with your wasabi credentials like this.
WAS_ACCESS_KEY_ID=4I349UKY85N1FR3D4BBW2
WAS_SECRET_ACCESS_KEY=Z1FOT1cWCuH7zDtEMv6pGZ9SmA2yspno7G
WAS_DEFAULT_REGION=ap-northeast-1
WAS_BUCKET=mybucket
WAS_URL=https://s3.ap-northeast-1.wasabisys.com
Step - 2: The S3 driver configuration information is located in your config/filesystems.php configuration file. This file contains an example configuration array for an S3 driver. You are free to modify this array with your own S3 configuration and credentials.
So, add your wasabi driver configuration information to config/filesystems.php
<?php
return [
'default' => env('FILESYSTEM_DRIVER', 'local'),
'cloud' => env('FILESYSTEM_CLOUD', 's3'),
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
'wasabi' => [
'driver' => 's3',
'key' => env('WAS_ACCESS_KEY_ID'),
'secret' => env('WAS_SECRET_ACCESS_KEY'),
'region' => env('WAS_DEFAULT_REGION'),
'bucket' => env('WAS_BUCKET'),
'endpoint' => 'https://s3.wasabisys.com'
],
],
];
Step - 3: Before using the S3 driver, you will need to install the Flysystem S3 package via the Composer package manager:
composer require league/flysystem-aws-s3-v3
Remember to give permission at your bucket access control.
'object write and read access' should have to enable before upload any file. like this -
Step - 4: Finally, you can upload your media file to your bucket of wasabi cloud storage using this -
\Illuminate\Support\Facades\Storage::disk('wasabi')>put($file, $fileContents, 'public');
check if file not exist and upload at your bucket-
if (!\Illuminate\Support\Facades\Storage::disk('wasabi')->exists($fileLocationInsideYourBucket)) {
\Illuminate\Support\Facades\Storage::disk('wasabi')->put($file, $fileContents, 'public');
}
You can also follow up the official guidance Wasabi Laravel to learn more.
Top comments (1)
Thank you bhai