jdavidbakr/signed-s3-filesystem

This package is abandoned and no longer maintained. The author suggests using the laravel/framework >5.5 package instead.

Extension of the Laravel S3 filesystem to return signed URLs

1.0.1 2017-10-20 15:04 UTC

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

Latest Version on Packagist Software License Total Downloads

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.