Skip to main content

Upload large files to S3 with ease

S3M handles multipart uploads for Laravel applications, breaking through the 5GB limit with parallel chunk uploads, automatic retries, and seamless serverless integration.

Quick Start

Get up and running with S3M in minutes

1

Install via Composer

Install the S3M package in your Laravel application:
composer require mreduar/s3m
The package will automatically register its service provider.
2

Publish configuration

Publish the S3M configuration file to customize settings:
php artisan vendor:publish --provider="MrEduar\S3M\S3MServiceProvider"
This creates config/s3m.php where you can configure AWS credentials, bucket settings, and upload options.
3

Add the Blade directive

Include the @s3m Blade directive in your layout file before your JavaScript:
@s3m
<script src="{{ asset('js/app.js') }}"></script>
This makes the s3m() helper function available globally in your frontend.
4

Upload your first file

Use the s3m() function in your JavaScript to upload files directly to S3:
const fileInput = document.querySelector('#file-input');

fileInput.addEventListener('change', (e) => {
  const file = e.target.files[0];
  
  s3m(file, {
    progress: (percent) => {
      console.log(`Upload progress: ${percent}%`);
    }
  }).then((response) => {
    console.log('Upload complete!', response);
    // Send metadata to your backend
    axios.post('/api/files', {
      uuid: response.uuid,
      key: response.key,
      bucket: response.bucket
    });
  });
});
{
  "uuid": "9d3e15e4-8b9a-4c7f-b2d1-6f4a8e9c1d2e",
  "key": "tmp/9d3e15e4-8b9a-4c7f-b2d1-6f4a8e9c1d2e",
  "bucket": "my-s3-bucket",
  "extension": "pdf",
  "name": "document.pdf",
  "url": "https://my-s3-bucket.s3.amazonaws.com/tmp/9d3e15e4-8b9a-4c7f-b2d1-6f4a8e9c1d2e"
}

Key Features

Everything you need for robust file uploads

Multipart uploads

Break through the 5GB S3 limit by splitting files into smaller chunks uploaded in parallel

Automatic retries

Configurable retry mechanism automatically handles failed chunk uploads without user intervention

Pre-signed URLs

Secure direct-to-S3 uploads using pre-signed URLs with built-in authorization checks

Progress tracking

Real-time upload progress callbacks for building responsive UIs with accurate progress bars

Serverless ready

Perfect for AWS Lambda and Laravel Vapor environments where local file storage isn’t available

Event hooks

Listen to upload lifecycle events to integrate with your application’s workflow

Ready to get started?

Follow our quickstart guide to install S3M and upload your first file in minutes.

Get Started Now

Build docs developers (and LLMs) love