Looking to hire Laravel developers? Try LaraJobs

laravel-s3-uploads maintained by saritasa

Description
laravel-s3-uploads
Last update
2021/03/05 07:42 (dev-master)
License
Downloads
1 048
Tags

Comments
comments powered by Disqus

laravel-s3-uploads

PHP Unit PHP CodeSniffer CodeCov Release PHPv Downloads

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.

Resources