Overview
The S3M package includes three FormRequest classes that handle validation and authorization for multipart upload operations. Each request class validates specific parameters and enforces configuration-based restrictions. Namespace:MrEduar\S3M\Http\Requests
CreateMultipartUploadRequest
Validates requests to create a new multipart upload session. Used by:POST /multipart endpoint
Authorization
All users must be authorized through theuploadFiles gate:
Validation Rules
Custom S3 bucket nameConstraints:
- Must be a string
- Can only be provided if
config('s3m.allow_change_bucket')istrue - Validation error if attempting to change bucket when disabled
S3 ACL visibility settingConstraints:
- Must be a string
- Must be
privateifconfig('s3m.allow_change_visibility')isfalse - Validation error if attempting to change visibility when disabled
MIME type of the file being uploadedConstraints:
- Must be a string
- No additional restrictions
Folder path within the bucketConstraints:
- Must be a string
- Must be
tmpifconfig('s3m.allow_change_folder')isfalse - Validation error if attempting to change folder when disabled
Example Usage
Validation Errors
SignPartRequest
Validates requests to generate presigned URLs for uploading file parts. Used by:POST /multipart/sign endpoint
Authorization
All users must be authorized through theuploadFiles gate:
Validation Rules
S3 object key (file path) from the create upload responseConstraints:
- Required field
- Must be a string
Part number for this upload chunkConstraints:
- Required field
- Must be an integer
- AWS S3 allows part numbers from 1 to 10,000
Upload ID from the create upload responseConstraints:
- Required field
- Must be a string
Custom S3 bucket nameConstraints:
- Must be a string
- No config restrictions for this request
S3 ACL visibility settingConstraints:
- Must be a string
- Must be
privateifconfig('s3m.allow_change_visibility')isfalse - Validation error if attempting to change visibility when disabled
MIME type for this partConstraints:
- Must be a string
- No additional restrictions
Example Usage
Validation Errors
CompleteMultipartUploadRequest
Validates requests to complete a multipart upload and assemble all parts. Used by:POST /multipart/complete endpoint
Authorization
All users must be authorized through theuploadFiles gate:
Validation Rules
Custom S3 bucket nameConstraints:
- Must be a string
- Can only be provided if
config('s3m.allow_change_bucket')istrue - Validation error if attempting to change bucket when disabled
S3 object key (file path) from the create upload responseConstraints:
- Required field
- Must be a string
Upload ID from the create upload responseConstraints:
- Required field
- Must be a string
Array of uploaded parts with their ETagsConstraints:
- Required field
- Must be an array
- Each element must contain
PartNumberandETag
Part number (must match the number used when uploading)Constraints:
- Required field
- Must be an integer
ETag value from the part upload response headersConstraints:
- Required field
- Must be a string
- Usually includes surrounding quotes (e.g.,
"abc123")
Example Usage
Validation Errors
Configuration Impact
The request validation behavior is controlled by these configuration options:allow_change_bucket
Config:config('s3m.allow_change_bucket')
Default: false
Impact:
- When
false: Users cannot specify a custom bucket inCreateMultipartUploadRequestorCompleteMultipartUploadRequest - When
true: Users can specify any bucket they have access to
allow_change_visibility
Config:config('s3m.allow_change_visibility')
Default: false
Impact:
- When
false: Visibility must beprivatein all requests - When
true: Users can specify any S3 ACL value (public-read,authenticated-read, etc.)
allow_change_folder
Config:config('s3m.allow_change_folder')
Default: false
Impact:
- When
false: Folder must betmpinCreateMultipartUploadRequest - When
true: Users can specify any folder path
Custom Authorization
To customize authorization logic, define theuploadFiles gate in your AuthServiceProvider: