-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fad8e66
commit 71f7486
Showing
8 changed files
with
270 additions
and
252 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"version":"pest_2.34.0","defects":{"P\\Tests\\Conversions\\ConversionOrientationTest::__pest_evaluable_it_can_correctly_convert_an_image_with_orientation_exif_data":7},"times":{"P\\Tests\\Conversions\\ConversionOrientationTest::__pest_evaluable_it_can_correctly_convert_an_image_with_orientation_exif_data":0.123}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
--- | ||
title: Handling uploads with Media Library Pro | ||
title: Media Library Pro | ||
weight: 4 | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
--- | ||
title: Customise | ||
weight: 2 | ||
--- | ||
|
||
## 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. | ||
|
||
```php | ||
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](https://laravel.com/docs/master/validation#rule-mimetypes) with the extensions [mentioned in this class](https://github.com/spatie/laravel-medialibrary-pro/blob/ba6eedd5b2a7f743909b441c0b6fd111d1a73794/src/Support/DefaultAllowedExtensions.php#L5) 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. | ||
|
||
```php | ||
// in config/medialibrary.php | ||
|
||
return [ | ||
// ... | ||
|
||
'temporary_uploads_allowed_extensions' => [ | ||
// your extensions | ||
... \Spatie\MediaLibraryPro\Support\DefaultAllowedExtensions::all(), // add this if you want to allow the default ones too | ||
], | ||
], | ||
] | ||
``` | ||
|
||
## 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](https://laravel.com/docs/master/rate-limiting#introduction) named `medialibrary-pro-uploads`. Typically, this would be done in a service provider. | ||
|
||
Here's an example where's we'll allow 15 files: | ||
|
||
```php | ||
// in a service provider | ||
|
||
use Illuminate\Support\Facades\RateLimiter; | ||
|
||
RateLimiter::for('medialibrary-pro-uploads', function (Request $request) { | ||
return [ | ||
Limit::perMinute(10)->by($request->ip()), | ||
]; | ||
}); | ||
``` | ||
|
10 changes: 10 additions & 0 deletions
10
docs/handling-uploads-with-media-library-pro/getting-started.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
title: Getting started | ||
weight: 2 | ||
--- | ||
|
||
Things to do to get started: | ||
|
||
- Get a license | ||
- Install the package | ||
- Configure your frontend |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.