jdavidbakr / signed-s3-filesystem
Extension of the Laravel S3 filesystem to return signed URLs
Installs: 2 615
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 1
Forks: 2
Open Issues: 1
Requires
- php: ~5.6|~7.0
- aws/aws-sdk-php-laravel: ^3.1
- illuminate/support: ~5.1
- league/flysystem-aws-s3-v3: ~1.0
Requires (Dev)
- orchestra/testbench-browser-kit: ~3.0
- phpunit/phpunit: ~4.0||~5.0
- squizlabs/php_codesniffer: ^2.3
This package is auto-updated.
Last update: 2019-12-04 19:03:00 UTC
README
As of Laravel 5.5, the Storage
facade contains this functionality internally. Therefore, it is recommended to sign your URLs according to the way Laravel intends.
signed-s3-filesystem
This package extends Laravel's S3 filesystem driver to return signed URLs via the Storage::url() command.
Install
Via Composer
$ composer require jdavidbakr/signed-s3-filesystem
Once installed, add the following to your providers array in cofig/app.php:
jdavidbakr\SignedS3Filesystem\SignedS3FilesystemServiceProvider::class,
This package makes use of the AWS facade, so be sure you have the following set in your providers array:
Aws\Laravel\AwsServiceProvider::class,
as well as in your alias array:
'AWS' => Aws\Laravel\AwsFacade::class,
You will also need to add the driver information to your config/filesystems.php file. This driver uses the same info as the S3 driver, with an additional parameter for the length of time until the signed URL will expire. If you do not specify an expiration time, URLs will default to expire 2 hours after being generated.
's3-signed' => [
'driver' => 's3-signed',
'key' => 'your-key',
'secret' => 'your-secret',
'region' => 'your-region',
'bucket' => 'your-bucket',
'options' => [
'expiration'=>'time-to-expire-urls-in-seconds',
],
],
Because the expiration option is optional, and everything else acts the same as the standard S3 driver, you can alternatively just change the driver value of the existing s3 section to 's3-signed'.
Usage
Use this driver in the same manner as you would any other Laravel filesystem driver. The Storage::url() command will return a signed URL.
$signed_url = Storage::disk('s3-signed')->url('path-to-file');
Testing
$ composer test
Contributing
Please see CONTRIBUTING and CONDUCT for details.
Security
If you discover any security related issues, please email me@jdavidbaker.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.