This is the documentation for
v11.
You can switch versions in the menu on the left/at the top.
Check your current version with the following command:
composer show spatie/laravel-medialibrary
##Only allow authenticated users to upload files
If in your project, you only want authenticated users to upload files, you can put the macro in a group that applies authentication middleware.
Route::middleware('auth')->group(function() {
Route::mediaLibrary();
});
We highly encourage you to do this, if you only need authenticated users to upload files.
##Configure allowed mime types
For security purposes, only files that pass Laravel's mimes
validation with the extensions mentioned in this class are allowed by the temporary upload controllers.
If you want your components to accept other mimetypes, add a key temporary_uploads_allowed_extensions
in the media-library.php
config file.
return [
'temporary_uploads_allowed_extensions' => [
... \Spatie\MediaLibraryPro\Support\DefaultAllowedExtensions::all(),
],
],
]
##Rate limiting
To protect you from users that upload too many files, the temporary uploads controllers are rate limited. By default, only 10 files can be upload per minute per ip iddress.
To customize rate limiting, add a rate limiter named medialibrary-pro-uploads
. Typically, this would be done in a service provider.
Here's an example where's we'll allow 15 files:
use Illuminate\Support\Facades\RateLimiter;
RateLimiter::for('medialibrary-pro-uploads', function (Request $request) {
return [
Limit::perMinute(10)->by($request->ip()),
];
});