Skip to main content

Laravel

Laravel's filesystem abstraction supports S3 out of the box via the league/flysystem-aws-s3-v3 adapter. Configure it with the Filebase endpoint and you can upload, download, and pre-sign URLs through Storage::disk('filebase').

Install

composer require league/flysystem-aws-s3-v3

Configure

config/filesystems.php
return [
'default' => env('FILESYSTEM_DISK', 'local'),

'disks' => [
// ...

'filebase' => [
'driver' => 's3',
'key' => env('FILEBASE_KEY'),
'secret' => env('FILEBASE_SECRET'),
'region' => 'auto',
'bucket' => env('FILEBASE_BUCKET'),
'endpoint' => 'https://s3.filebase.io',
'throw' => true,
'visibility' => 'public', // or 'private'
],
],
];
.env
FILEBASE_KEY=your-access-key
FILEBASE_SECRET=your-secret-key
FILEBASE_BUCKET=my-laravel-app

Upload a file

use Illuminate\Support\Facades\Storage;

// From a request upload
$path = $request->file('photo')->store('photos', 'filebase');

// From a string
Storage::disk('filebase')->put('hello.txt', 'Hello, world!');

// From a stream
Storage::disk('filebase')->putStream(
'video.mp4',
fopen(storage_path('app/local-video.mp4'), 'r'),
);

Download / read a file

$contents = Storage::disk('filebase')->get('photos/cat.jpg');
$exists = Storage::disk('filebase')->exists('photos/cat.jpg');
$size = Storage::disk('filebase')->size('photos/cat.jpg');

To stream a file as an HTTP response:

return Storage::disk('filebase')->response('photos/cat.jpg');

Public URLs

For public buckets, generate a public URL:

$url = Storage::disk('filebase')->url('photos/cat.jpg');
// → https://my-laravel-app.s3.filebase.io/photos/cat.jpg

Pre-signed URLs

For private buckets, generate a temporary URL:

$url = Storage::disk('filebase')->temporaryUrl(
'docs/contract.pdf',
now()->addHour(),
);

For uploads:

$url = Storage::disk('filebase')->temporaryUploadUrl(
'uploads/' . auth()->id() . '/' . $filename,
now()->addMinutes(10),
);

Delete a file

Storage::disk('filebase')->delete('photos/cat.jpg');

// Bulk delete
Storage::disk('filebase')->delete([
'photos/cat.jpg',
'photos/dog.jpg',
]);

List files

$files = Storage::disk('filebase')->files('photos');
$dirs = Storage::disk('filebase')->directories('photos');

// Recursive
$allFiles = Storage::disk('filebase')->allFiles('photos');

Use as the default disk

FILESYSTEM_DISK=filebase

Now Storage::put(...), Storage::get(...), etc. operate against Filebase by default — no per-call disk argument needed.

What's next