Download the PHP package appoly/s3-uploader without Composer
On this page you can find all versions of the php package appoly/s3-uploader. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package s3-uploader
🚀 S3 Uploader for Laravel
A Laravel package for handling S3 multipart uploads with presigned URLs. Perfect for uploading large files directly from the browser to S3.
✨ Features
- 📤 Multipart uploads - Upload large files in chunks
- 🔐 Presigned URLs - Secure, time-limited upload URLs
- ⚡ Direct to S3 - Browser uploads directly to S3, bypassing your server
- 🎛️ Configurable - Flexible configuration options
- 🛣️ Optional routes - Use built-in routes or define your own
- 🏗️ Facade & DI - Use however you prefer
📦 Installation
⚙️ Configuration
Publish the config file:
By default, the package uses your s3 filesystem disk configuration. Override in config/s3-uploader.php or via environment variables.
🔑 Environment Variables
| Variable | Default | Description |
|---|---|---|
S3_UPLOADER_BUCKET |
S3 disk bucket | S3 bucket name |
S3_UPLOADER_REGION |
S3 disk region | AWS region (e.g., eu-west-2) |
S3_UPLOADER_KEY |
S3 disk key | AWS Access Key ID |
S3_UPLOADER_SECRET |
S3 disk secret | AWS Secret Access Key |
S3_UPLOADER_ENDPOINT |
S3 disk endpoint | Custom endpoint for S3-compatible services (MinIO, DigitalOcean Spaces, etc.) |
S3_UPLOADER_PATH_STYLE |
false |
Use path-style URLs instead of virtual-hosted style (required for some S3-compatible services) |
S3_UPLOADER_PATH_PREFIX |
uploads/multipart |
Prefix path for uploaded files in S3 |
S3_UPLOADER_URL_EXPIRATION |
+60 minutes |
How long presigned URLs remain valid |
S3_UPLOADER_WRAP_RESPONSES |
false |
Wrap responses in {success, message, data} envelope |
🚀 Usage
Using the Facade
Using Dependency Injection
🗄️ Config Options
You can also configure the package directly in config/s3-uploader.php:
🛣️ API Endpoints
The package registers these routes by default (can be customized via routes.prefix and routes.middleware):
| Method | Endpoint | Route Name | Description |
|---|---|---|---|
POST |
/api/s3/multipart/initiate |
s3-uploader.initiate |
Start a multipart upload |
POST |
/api/s3/multipart/presign-part |
s3-uploader.presign-part |
Get presigned URL for a part |
POST |
/api/s3/multipart/complete |
s3-uploader.complete |
Complete the upload |
POST |
/api/s3/multipart/abort |
s3-uploader.abort |
Abort the upload |
POST /api/s3/multipart/initiate
Start a new multipart upload session.
| Headers: | Header | Required | Value |
|---|---|---|---|
Content-Type |
Yes | application/json |
|
Accept |
Yes | application/json |
| Request Body: | Parameter | Type | Required | Description |
|---|---|---|---|---|
file_name |
string | Yes | Original filename (e.g., video.mp4) |
|
content_type |
string | No | MIME type (default: application/octet-stream) |
Example Request:
Example Response:
POST /api/s3/multipart/presign-part
Get a presigned URL to upload a specific part directly to S3.
| Headers: | Header | Required | Value |
|---|---|---|---|
Content-Type |
Yes | application/json |
|
Accept |
Yes | application/json |
| Request Body: | Parameter | Type | Required | Description |
|---|---|---|---|---|
upload_id |
string | Yes | Upload ID from initiate response | |
file_path |
string | Yes | File path from initiate response | |
part_number |
integer | Yes | Part number (starts at 1) |
Example Request:
Example Response:
POST /api/s3/multipart/complete
Complete the multipart upload after all parts have been uploaded to S3.
| Headers: | Header | Required | Value |
|---|---|---|---|
Content-Type |
Yes | application/json |
|
Accept |
Yes | application/json |
| Request Body: | Parameter | Type | Required | Description |
|---|---|---|---|---|
upload_id |
string | Yes | Upload ID from initiate response | |
file_path |
string | Yes | File path from initiate response | |
parts |
array | Yes | Array of uploaded parts | |
parts.*.part_number |
integer | Yes | Part number | |
parts.*.etag |
string | Yes | ETag returned by S3 after uploading the part |
Example Request:
Example Response:
POST /api/s3/multipart/abort
Abort an in-progress multipart upload and clean up any uploaded parts.
| Headers: | Header | Required | Value |
|---|---|---|---|
Content-Type |
Yes | application/json |
|
Accept |
Yes | application/json |
| Request Body: | Parameter | Type | Required | Description |
|---|---|---|---|---|
upload_id |
string | Yes | Upload ID from initiate response | |
file_path |
string | Yes | File path from initiate response |
Example Request:
Example Response:
📦 Response Wrapping
By default, endpoints return flat JSON responses. Enable wrap_responses to wrap all responses in a standard envelope — useful for APIs that follow a {success, message, data} convention.
Wrapped success response:
Wrapped error response (500):
When wrap_responses is false (default), responses are returned as flat JSON and errors are returned as standard Laravel exception responses.
🎨 Customizing Routes
Disable default routes and define your own:
Then in your routes file:
🌐 Frontend Example
Here's a basic JavaScript example for uploading:
🏢 Credits
Made with ❤️ by Appoly