⚠️ If you're new to Backblaze, use this guide before proceeding.
$ composer require league/flysystem-aws-s3-v3 "^3.0" --with-all-dependencies
AWS_ACCESS_KEY_ID=YOUR_APPLICATION_KEY_ID # ex. 0050cXXXXXXXXXXX
AWS_SECRET_ACCESS_KEY=YOUR_APPLICATION_ACCESS_KEY_ID # K005XXXXXXXXXXXXXXXXX
AWS_DEFAULT_REGION=BUCKET_REGION # ex. us-east-001
AWS_BUCKET=YOUR_BUCKET_NAME # ex. testbackblaze
AWS_ENDPOINT=https://s3.BUCKET_REGION.backblazeb2.com # ex. https://s3.us-east-001.backblazeb2.com
Create a command:
$ php artisan make:command TestS3
Copy and paste the following content into the created file:
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Storage;
class TestS3 extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'app:test-s3';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Test S3 connection with Backblaze';
/**
* Execute the console command.
*/
public function handle()
{
$s3 = Storage::disk('s3');
$s3->put('test.txt', 'Hello World');
if ($s3->exists('test.txt')) {
$this->info('Everything is ok');
} else {
$this->error('Something went wrong');
}
}
}
Run the command
php artisan app:test-s3
That's it! ✅