API / Minn\Media / Upload

Upload final readonly class

Minn\Media\Upload · public/minn/src/Minn/Media/Upload.php · 89 lines

One file arriving for the library, on either transport: a multipart field named "file" (a temporary upload to move) or a raw body whose Content-Disposition names the file. The parent is read from the same request, wherever the client put it.

Constants and properties

propreadonly string $filename

Promoted from the constructor.

propreadonly ?string $movedFrom

Promoted from the constructor.

propreadonly ?string $raw

Promoted from the constructor.

propreadonly int $parent

Promoted from the constructor.

Public

new__construct(string $filename, ?string $movedFrom, ?string $raw, int $parent = 0)#
staticfromRequest(Minn\Http\Request $request): ?self#

Null when the request carries no file.

staticfilenameFrom(array $headers): ?string#

The file a Content-Disposition names, as the reference reads one (probe rest-attachments-controller): the parameters after the disposition type, split on semicolons as written; the last non-empty filename= of all the headers, unquoted when double quotes wrap it. "filename" is matched as written, and filename* is not read. Null when none names one.

$headerslist<string>
staticrefusal(string $data, array $headers): ?Minn\RestError#

Why a raw body cannot be taken, in the reference's order: no data, no Content-Type, no Content-Disposition, one naming no file, a Content-MD5 the data does not match. Null when it can. The headers are the REST request's, keyed by lower-case names with underscores.

$headersarray<string, list<string>>
methodmime(): ?string#

The mime type the extension maps to, or null for one the library refuses.

staticparentOf(Minn\Http\Request $request): int#

The post the client wants the file attached to: form field, query, or JSON body.