PHPackages                             mreduar/s3m - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. mreduar/s3m

ActiveLibrary[File &amp; Storage](/categories/file-storage)

mreduar/s3m
===========

Multipart Uploads using Laravel and AWS S3

v2.0.0(2mo ago)173.6k—9.1%1[1 PRs](https://github.com/mreduar/s3m/pulls)MITPHPPHP ^8.2CI passing

Since Jul 22Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/mreduar/s3m)[ Packagist](https://packagist.org/packages/mreduar/s3m)[ Docs](https://github.com/mreduar/s3m)[ GitHub Sponsors]()[ RSS](/packages/mreduar-s3m/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (8)Dependencies (28)Versions (11)Used By (0)

[![Multipart Uploads using Laravel and AWS S3](https://raw.githubusercontent.com/mreduar/s3m/main/s3m-banner.png)](https://raw.githubusercontent.com/mreduar/s3m/main/s3m-banner.png)

S3M - Multipart Uploads using Laravel and AWS S3
================================================

[](#s3m---multipart-uploads-using-laravel-and-aws-s3)

[![Latest Version on Packagist](https://camo.githubusercontent.com/c20895e77f92de5ec0f176a407cbdce789eaa6e4e9fb90ef8f6baa5c89766918/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d7265647561722f73336d2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mreduar/s3m)[![GitHub Tests Action Status](https://camo.githubusercontent.com/cd71436f2cb43c9078b9ea4f63156b650191431d1da5236b84271563c02d88ec/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d7265647561722f73336d2f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/mreduar/s3m/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/9ec45cb1a133ab557f2736a60422d5efdbd11eaedb337b09120618009288c779/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d7265647561722f73336d2f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/mreduar/s3m/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/1fefab8de5067d3ed45f51f6914ceced7d327819e7b3920b5acfafd522183a54/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d7265647561722f73336d2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mreduar/s3m)

Sometimes when running an application in a serverless environment, you may not store files permanently on the local filesystem, since you can never be sure that the same serverless "container" will be used on a subsequent request. All files should be stored in a cloud storage system, such as AWS S3, or in a shared file system through AWS EFS. Or, you may want to send a file directly to Amazon S3 simply because you don't want the server to receive files directly.

When uploading large files to S3, you may run into the 5GB limit for a single PUT request. This package allows you to upload large files to S3 by splitting the file into smaller parts and uploading them in parallel.

- [**Features**](#features)
- [**Architecture**](#architecture)
- [**Installation**](#installation)
- [**Usage**](#usage)
    - [Authorization](#authorization)
    - [Streaming Files To S3](#streaming-files-to-s3)
    - [Acknowledge File Uploads &amp; Permanent Storage](#acknowledge-file-uploads--permanent-storage)
- [**Changelog**](#changelog)
- [**Contributing**](#contributing)
- [**Security Vulnerabilities**](#security-vulnerabilities)
- [**Credits**](#credits)
- [**License**](#license)

Features
--------

[](#features)

- Upload large files that exceed the 5GB limit
- Upload files in parallel
- Retry failed uploads automatically
- Configurable Chunked uploads
- Configurable number of parallel uploads
- Authorization checks before uploading files
- Configurable retry attempts

Architecture
------------

[](#architecture)

 ```
sequenceDiagram
  autonumber
  participant User
  participant Browser (SPA)
  participant Server
  participant API Gateway/Lambda
  participant S3
  User-->>Browser (SPA):Open Web App
  Browser (SPA)-->>Server:Get App
  User-->>Browser (SPA):Upload File
  Browser (SPA)-->>API Gateway/Lambda:Initialize Multipart Upload
  API Gateway/Lambda-->>S3:Get Upload ID
  Browser (SPA)-->>API Gateway/Lambda:Get Multipart PreSigned URLs
  API Gateway/Lambda-->>S3:Get Presigned URLs
  par Parallel Upload
    Browser (SPA)-->>Browser (SPA):Make part 1
    Browser (SPA)-->>S3:Upload Part 1
  end
  Browser (SPA)-->>API Gateway/Lambda:Finalize Multipart Upload
  API Gateway/Lambda-->>S3:Mark upload complete

```

      Loading Installation
------------

[](#installation)

You can install the package via composer:

```
composer require mreduar/s3m
```

Add the `@s3m` Blade directive to your main layout (*before* your application's JavaScript), and the `s3m()` helper function will be available globally!

### Configuration

[](#configuration)

S3M's default configuration settings can be customized. First, publish the configuration file:

```
php artisan vendor:publish --provider="MrEduar\S3M\S3MServiceProvider"
```

This will create `config/s3m.php` in your project. There, you can customize S3M's configuration, including the AWS environment settings.

Usage
-----

[](#usage)

### Authorization

[](#authorization)

Before initiating an upload directly to S3, S3M's internal signed storage URL generator will perform an authorization check against the currently authenticated user. If you do not already have one, you should create a `UserPolicy` for your application using the following command:

```
php artisan make:policy UserPolicy --model=User
```

Next, you should add an `uploadFiles` method to this policy. This method should return `true` if the given authenticated user is allowed to upload files. Otherwise, you should return `false`:

```
/**
 * Determine whether the user can upload files.
 *
 * @param  \App\User  $user
 * @return mixed
 */
public function uploadFiles(User $user)
{
    return true;
}
```

### Streaming Files To S3

[](#streaming-files-to-s3)

You may use the `s3m()` method within your frontend code to upload a file directly to the S3 bucket attached to your environment. The following example demonstrates this functionality using Vue:

```

const uploadFile = (e) => {
    const file = e.target.files[0];

    s3m(file, {
        progress: progress => {
            uploadProgress.value = progress;
        }
    }).then((response) => {
        axios.post('/api/profile-photo', {
            uuid: response.uuid,
            key: response.key,
            bucket: response.bucket,
            name: file.value.name,
            content_type: file.value.type,
        })
    });
};
```

All uploaded files will be placed in a `tmp` directory within the bucket. This directory should be configured to automatically purge any files older than 24 hours. This feature serves to conveniently clean up file uploads that are initiated but not completed, such as a user that begins updating their profile photo but does not save the change.

The `tmp` directory is private by default. To override this for a given file you may add a `visibility` property to the options provided to the `s3m()` method. The `visibility` property should be assigned one of [S3's predefined permission grants](https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#canned-acl):

```
s3m(file, {
    visibility: 'public-read',
}).then((response) => {
    // ...
});
```

### Acknowledge File Uploads &amp; Permanent Storage

[](#acknowledge-file-uploads--permanent-storage)

All uploaded files will be stored using a UUID as their filename. The `response` provided to the `s3m` method's `then` callback will contain the UUID of the file, the file's full S3 key, and the file's bucket. You may then POST this information to your application's backend to permanently store the file by moving it out of the bucket's `tmp` directory. In addition, you may wish to store additional information about the file, such as its original name and content type, in your application's database:

```
use Illuminate\Support\Facades\Storage;

Storage::copy(
    $request->input('key'),
    str_replace('tmp/', '', $request->input('key'))
);
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Eduar Bastidas](https://github.com/mreduar)
- [All Contributors](../../contributors)

This project is inspired by [Laravel Vapor](https://vapor.laravel.com/). The architecture and design of this package is influenced by the work of the Laravel team and other resources.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

51

—

FairBetter than 96% of packages

Maintenance89

Actively maintained with recent releases

Popularity31

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 76.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~75 days

Recently: every ~121 days

Total

9

Last Release

62d ago

Major Versions

v1.4.0 → v2.0.02026-03-17

PHP version history (2 changes)v1.0.0PHP ^8.1

v1.4.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/7b5b586d75cd9a9f79eedadc9259b5202fe3e3eb2a96d8311b51ac6463a6bd3c?d=identicon)[mreduar](/maintainers/mreduar)

---

Top Contributors

[![mreduar](https://avatars.githubusercontent.com/u/22550119?v=4)](https://github.com/mreduar "mreduar (65 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (12 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (6 commits)")[![aaronaccessvr](https://avatars.githubusercontent.com/u/79271047?v=4)](https://github.com/aaronaccessvr "aaronaccessvr (1 commits)")[![aaronredwood](https://avatars.githubusercontent.com/u/50202473?v=4)](https://github.com/aaronredwood "aaronredwood (1 commits)")

---

Tags

amazon-s3amazon-s3-multipartlaravellaravel-packages3-multipart-uploads3-uploadsserverlesssigned-urllaravelEduar Bastidass3m

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/mreduar-s3m/health.svg)

```
[![Health](https://phpackages.com/badges/mreduar-s3m/health.svg)](https://phpackages.com/packages/mreduar-s3m)
```

###  Alternatives

[aws/aws-sdk-php-laravel

A simple Laravel 9/10/11/12/13 service provider for including the AWS SDK for PHP.

1.7k35.6M75](/packages/aws-aws-sdk-php-laravel)[spatie/livewire-filepond

Upload files using Filepond in Livewire components

306452.7k3](/packages/spatie-livewire-filepond)[elegantly/laravel-invoices

Store invoices safely in your Laravel application

23131.8k](/packages/elegantly-laravel-invoices)[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)[mwguerra/filemanager

A full-featured file manager package for Laravel and Filament v5 with dual operating modes, drag-and-drop uploads, S3/MinIO support, and comprehensive security features.

718.5k1](/packages/mwguerra-filemanager)[codebar-ag/laravel-flysystem-cloudinary

Cloudinary Flysystem v1 integration with Laravel

1224.9k2](/packages/codebar-ag-laravel-flysystem-cloudinary)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
