Options & enums
The values the SDK takes in parameters and returns in entity fields. The enums mirror the server’s — the same cases and the same values.
ImageOptions
What to do with an image at upload: re-encode, set the quality, fit into a box. Processing runs once on the server, only the result lands in the bucket, the original is not kept. EXIF rotation is applied, other metadata is dropped.
An immutable object: every method returns a new one.
Creating
public function __construct(
ImageFormat $format = ImageFormat::ORIGINAL,
?int $quality = null,
?int $maxWidth = null,
?int $maxHeight = null,
)
public static function original(): ImageOptions
public static function webp(?int $quality = null): ImageOptions
public static function jpeg(?int $quality = null): ImageOptions
public static function png(?int $quality = null): ImageOptions
public static function avif(?int $quality = null): ImageOptions| Parameter | Type | Limits | Default | Description |
|---|---|---|---|---|
$format |
ImageFormat |
— | ORIGINAL |
what to re-encode into; ORIGINAL — keep the format |
$quality |
?int |
1–100 | the server’s: 82; PNG — 60; AVIF — 55 | encoder quality |
$maxWidth |
?int |
16–10000 | no limit | fit by width |
$maxHeight |
?int |
16–10000 | no limit | fit by height |
The server checks the limits: a value beyond them gives ValidationException with a per-field
error, e.g. {"quality": ["must not exceed 100"]}.
ImageOptions::fit()
Fits the image into a box. It only shrinks, never enlarges, and keeps the aspect ratio: 320×200 in a 160×160 box becomes 160×100.
public function fit(?int $maxWidth, ?int $maxHeight = null): ImageOptionsfit(800) limits only the width; fit(null, 600) — only the height.
ImageOptions::quality()
Sets the quality and keeps the rest.
public function quality(int $quality): ImageOptionsImageOptions::isEmpty()
true if the options ask for nothing: format ORIGINAL, no quality or sizes set. The server does
not apply such options at all — processed->reason will be no options.
public function isEmpty(): boolExamples
use Flytachi\Winter\SDK\S5w\Option\ImageOptions;
ImageOptions::webp(); // WebP, quality 82
ImageOptions::webp(80)->fit(1600, 1600); // WebP 80, fit into 1600×1600
ImageOptions::avif(50); // AVIF 50
ImageOptions::original()->fit(800); // keep the format, width at most 800
ImageOptions::jpeg()->quality(90); // JPEG 90Images only
Options sent with a file that is not an image are refused by the server —
ValidationException (Image options were given, but this file is not an image).
ImageFormat
What to re-encode an image into. A string-backed enum.
| Case | Value | MIME | Extension after upload |
|---|---|---|---|
ORIGINAL |
'ORIGINAL' |
— | unchanged |
WEBP |
'WEBP' |
image/webp |
.webp |
JPEG |
'JPEG' |
image/jpeg |
.jpg |
PNG |
'PNG' |
image/png |
.png |
AVIF |
'AVIF' |
image/avif |
.avif |
Methods
mime(): ?string — the format’s MIME type; null for ORIGINAL.
Retention
How long a folder’s files live, counted from each file’s creation. The server’s sweep runs every five minutes, so deletion is prompt but not instant.
| Case | Value | Period |
|---|---|---|
NONE |
0 |
forever |
DAY |
1 |
a day |
WEEK |
2 |
a week |
MONTH |
3 |
a month |
QUARTER |
4 |
three months |
HALF_YEAR |
5 |
half a year |
YEAR |
6 |
a year |
Methods
interval(): ?DateInterval — the period as an interval; null for NONE.
$file->createdAt->add($folder->retention->interval()); // when the file is deleted(The exact deletion time is also on the file itself — $file->expiresAt.)
CacheVisibility
Who may cache a file — the directive of its Cache-Control header.
| Case | Value | Directive | Meaning |
|---|---|---|---|
SHARED |
1 |
public |
browsers and CDNs |
PRIVATE |
2 |
private |
the browser only, no shared caches |
NO_STORE |
3 |
no-store |
nobody |
Methods
directive(): string — the directive for Cache-Control.
TokenAccess
A key’s access level — the KeyInfo::$access field.
| Case | Value | What it opens |
|---|---|---|
BASIC |
1 |
only check() and /p/{id} delivery |
FULL |
2 |
everything: folders, files, uploads |
Methods
isFull(): bool — whether the key can work with folders(), files() and uploads().
if (!$s5w->check()->access->isFull()) {
throw new RuntimeException('A FULL key is required');
}FileSort
The sort field in files()->list() and files()->all().
| Case | Value | Order |
|---|---|---|
CREATED |
'created' |
by upload time (default) |
NAME |
'name' |
by name, case-sensitive (capitals before lower case) |
TYPE |
'type' |
by MIME type, then name |
SIZE |
'size' |
by size, then name |
SortDirection
| Case | Value |
|---|---|
ASC |
'asc' — ascending |
DESC |
'desc' — descending (default) |