Direct To Storage
The directToStorage method sends the bytes from the browser to a Laravel filesystem disk instead of proxying them through PHP. It follows Laravel's Storage model: you configure a disk in config/filesystems.php, then tell the field which disk receives the upload.
use InertiaUI\Forms\Fields\File;
File::make('archive')
->directToStorage('s3')
->partSize(16 * 1024 * 1024)
->multipartThreshold(100 * 1024 * 1024);Laravel still controls the upload. It creates the signed URLs, validates the completed object, runs custom validators, returns the encrypted temporary upload token, and later exposes that token as a SubmittedUpload during form submission. Only the file bytes go straight from the browser to S3, MinIO, or another S3-compatible disk.
Files at or below the multipart threshold use one signed PUT. Larger files use S3 multipart upload parts and may resume from the parts already uploaded.
The argument of the directToStorage method is a Laravel disk name from config/filesystems.php, just like Storage::disk('s3'). Most applications only need to configure a normal S3-compatible disk and pass its name to the field.
Completed Upload Immutability
Completing a direct upload moves the object to a fresh key and spends the upload handle before Laravel validates the file. The original upload URL therefore can't write to the validated object.
- Package-mediated writes and repeated completion return
409. - An unexpired S3
PUTURL may only recreate the abandoned original key. - By default,
store(),storeAs(), explicit deletion, and aborts remove the whole temporary upload directory. - S3 multipart abort failures propagate without reporting successful cleanup.
The browser writes S3 objects as application/octet-stream, whatever type the client declares. Completing the upload sets the object's Content-Type to the type detected from its first megabyte, so S3 never serves a file with a type the client chose.
S3 Configuration
Install Laravel's S3 filesystem adapter in the consuming application:
composer require league/flysystem-aws-s3-v3Configure a normal Laravel s3 disk in config/filesystems.php, then point Inertia Forms at that disk:
// config/inertia-forms.php
return [
'file_uploads' => [
'direct_to_storage' => [
'disk' => 's3',
'url_lifetime' => 900,
'part_size' => 16 * 1024 * 1024,
'multipart_threshold' => 100 * 1024 * 1024,
],
],
];Publish the runtime config as described in Installation. See Direct To Storage for the full option reference.
Your bucket's CORS policy must allow browser PUT requests from your application's origin. It must also expose the ETag header, so multipart completion may send the uploaded part identifiers back to Laravel. The minimum CORS policy looks like this:
[
{
"AllowedOrigins": ["https://your-app.example"],
"AllowedMethods": ["PUT"],
"AllowedHeaders": ["*"],
"ExposeHeaders": ["ETag"],
"MaxAgeSeconds": 3600
}
]MinIO
MinIO uses Laravel's normal s3 filesystem driver, so you may define it as a normal Laravel filesystem disk:
// config/filesystems.php
return [
'disks' => [
'minio' => [
'driver' => 's3',
'key' => env('MINIO_ACCESS_KEY_ID', 'minioadmin'),
'secret' => env('MINIO_SECRET_ACCESS_KEY', 'minioadmin'),
'region' => env('MINIO_REGION', 'us-east-1'),
'bucket' => env('MINIO_BUCKET', 'inertia-forms-tests'),
'endpoint' => env('MINIO_ENDPOINT', 'http://127.0.0.1:9000'),
'use_path_style_endpoint' => true,
'throw' => true,
],
],
];Then use that disk globally or per field:
File::make('archive')->directToStorage('minio');Local MinIO setups may configure browser CORS globally with MINIO_API_CORS_ALLOW_ORIGIN instead of accepting S3 bucket CORS through PutBucketCors. The browser requirement stays the same: your application's origin must be allowed to send the signed PUT requests, and multipart responses must expose ETag.