S3StorageDriver
in package
implements
StorageDriverInterface
Amazon S3 storage driver.
Uploads processed images to S3 with public-read ACL. Supports optional CloudFront CDN URL via AWS_S3_URL env var.
Tags
Table of Contents
Interfaces
- StorageDriverInterface
- Interface for storage drivers (local filesystem, S3, etc.).
Properties
Methods
- __construct() : mixed
- Create the S3 driver from environment variables.
- delete() : void
- Delete a file from S3.
- exists() : bool
- Check if an object exists in S3.
- name() : string
- Get the driver name.
- put() : string
- Upload a local file to S3 with public-read ACL.
- url() : string
- Get the public URL for an S3-stored file.
Properties
$bucket
private
string
$bucket
S3 bucket name
$cdnUrl
private
string|null
$cdnUrl
Optional CDN/custom URL prefix
$client
private
S3Client
$client
$region
private
string
$region
AWS region
Methods
__construct()
Create the S3 driver from environment variables.
public
__construct() : mixed
Tags
delete()
Delete a file from S3.
public
delete(string $storagePath) : void
Parameters
- $storagePath : string
-
Relative storage path (S3 object key)
exists()
Check if an object exists in S3.
public
exists(string $storagePath) : bool
Parameters
- $storagePath : string
-
S3 object key
Return values
boolname()
Get the driver name.
public
name() : string
Return values
string —'local' or 's3'
put()
Upload a local file to S3 with public-read ACL.
public
put(string $localPath, string $storagePath, string $mimeType) : string
Parameters
- $localPath : string
-
Absolute path to the local file
- $storagePath : string
-
Relative storage path (used as S3 object key)
- $mimeType : string
-
MIME type
Tags
Return values
string —The storage path
url()
Get the public URL for an S3-stored file.
public
url(string $storagePath) : string
Uses CDN URL if configured, otherwise default S3 URL.
Parameters
- $storagePath : string
-
Relative storage path (S3 object key)
Return values
string —Full URL