saritasa / laravel-s3-uploads
laravel-s3-uploads
Installs: 1 041
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 9
Forks: 0
Open Issues: 0
Requires
- php: >=7.1
- illuminate/database: ^5.4 || ^6.0
- illuminate/http: ^5.4 || ^6.0
- illuminate/support: ^5.4 || ^6.0
- league/flysystem-aws-s3-v3: ^1.0
- saritasa/dingo-api-custom: ^2.2
- saritasa/php-common: ^1.1
Requires (Dev)
- phpunit/phpunit: ^6.0
- squizlabs/php_codesniffer: ^3.0
README
Laravel API for S3 uploads
Usage
Install the saritasa/laravel-s3-uploads
package:
$ composer require saritasa/laravel-s3-uploads
Configure Your Storage::cloud()
disk for AWS S3 accroding to Laravel Manual
This package exposes POST <API_PREFIX>/uploads/tmp
route, using Dingo/Api router.
It accepts application/json
request in form:
{ "fileName": "image.jpg" }
and returns response with S3 PreSigned URLs as
{ "uploadUrl": "https://my-bucket.s3-us-west.amazonaws.com/tmp/1341234uoi123lhkj1.jpg?<WRITE_SIGNATURE=...>", "validUntil": "2017-04-12T23:20:50.52Z", "fileUrl": "https://my-bucket.s3-us-west.amazonaws.com/tmp/1341234uoi123lhkj1.jpg?<READ_SIGNATURE=...>" }
- uploadUrl can be used with
PUT <uploadUrl>
on frontend to upload URL to S3 directly. - fileUrl is a presigned URL, that can be used to read this file on frontend after upload (supposing, that your S3 bucket has default policy to set 'private' ACL for new files).
Configuration
You can use config/media.php
to change default uploads path within bucket or presigned urls expiration timeouts.
Contributing
See CONTRIBUTING and Code of Conduct, if you want to make contribution (pull request) or just build and test project on your own.