Configuration
Store credentials inconfig/services.php and the environment, never in code.
.env. Use your deployment platform’s secret store in production.
A small client
Uploading a file
Http::attach() streams from disk when you pass a path with a resource, but be explicit about memory.
Downloading a file
Stream to a response instead of buffering the whole file in PHP memory.Content-Disposition header without sanitizing it.
Error handling
Laravel’sthrow() raises RequestException for 4xx/5xx. Decode the envelope yourself so you can branch on code.
Queues and timeouts
Large uploads do not belong in a synchronous web request.- Push uploads to a queued job with a generous timeout.
- Set
retry_afterabove your job timeout so jobs are not duplicated. - Make the job idempotent by recording the resulting
fileId. - Do not retry a failed upload blindly; check whether the object already exists.
Security checklist
- Credentials only from environment or a secret manager.
- Key scoped to the operations you actually use.
- Key restricted to the buckets you actually use.
- Uploaded files treated as untrusted content.
- File type and size validated before upload.
- Filenames sanitized for display and headers.
- No secrets in logs, including exception traces.
- Separate keys per environment.
Related
Upload files
Upload semantics and limits.
Download files
Streaming and ranges.
Authentication
Key model and scopes.
Error codes
Stable codes.