I am working on a Laravel project and decided to use a Backblaze bucket as it’s cheaper for storage when compared to AWS S3. I couldn’t find a tutorial on how to get it working from scratch and I tested a bunch of Laravel B2 libraries that didn’t end up working. The good news is that you don’t need a special B2 plugin and instead can use the S3 package recommended by the Laravel docs.

If you haven’t added the flysystem-aws-s3 package, add it to your project using composer:

composer require league/flysystem-aws-s3-v3

Login to your B2 account and create your bucket with your required settings. Once created, you’ll want to create a new application key with the permissions you need for your app. You should get a confirmation once it’s generated:

Open your .env file and locate the settings for AWS. You’ll need to add one key that’s not there by default:

AWS_ENDPOINT=

Match the settings in your .env from the application key to the values below.

AWS_ACCESS_KEY_ID=keyID
AWS_SECRET_ACCESS_KEY=applicationKey
AWS_DEFAULT_REGION=us-west-000
AWS_BUCKET=bucket-name
AWS_ENDPOINT=S3 Endpoint

Now you should be able to call the Laravel storage system like normal:

\Storage::disk('s3')->put('test.txt', 'test');
There are currently no comments.

Leave a Reply