laravel-local-temporary-upload-url maintained by mnapoli
Laravel Local Temporary Upload URL
Adds temporaryUploadUrl() support to Laravel's local filesystem driver.
This allows the same S3 upload flow (presigned URL + direct PUT) to work in local development without requiring S3/MinIO.
Installation
composer require mnapoli/laravel-local-temporary-upload-url
The package auto-registers its service provider.
Usage
Use temporaryUploadUrl() exactly like you would with S3:
use Illuminate\Support\Facades\Storage;
[$url, $headers] = Storage::temporaryUploadUrl(
'uploads/my-file.txt',
now()->addMinutes(5)
);
Then upload directly via PUT:
await fetch(url, {
method: 'PUT',
body: file,
});
Configuration
Optionally publish the config file:
php artisan vendor:publish --provider="LocalTemporaryUpload\LocalTemporaryUploadServiceProvider" --tag=config
Frontend example
async function uploadFile(file) {
// Get the presigned URL from your backend
const response = await fetch('/api/upload-url', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ filename: file.name }),
});
const { url } = await response.json();
// Upload directly to the signed URL
await fetch(url, {
method: 'PUT',
body: file,
});
}