saritasa/laravel-s3-uploads

This package is abandoned and no longer maintained. No replacement package was suggested.

laravel-s3-uploads

1.2.0 2021-02-02 13:40 UTC

This package is auto-updated.

Last update: 2024-09-05 13:48:36 UTC


README

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