FileService<Tk,Tv>
Interface for storing and retrieving uploaded files.
Instance Methods
| Returns | Signature and Description |
|---|---|
void | delete()Deletes a stored file. |
StreamInterface | messageStream()Gets the file as a PSR-7 Stream. |
?Tv | read()Gets a stored file. |
Traversable<Tv> | readAll()Finds several files by some arbitrary criteria. |
resource | resource()Gets a stream resource for the given ID. |
Tk | store(, )Stores an uploaded file. |
void | stream(, )Efficiently writes the contents of a file to a Stream. |
Method Details
delete
delete(mixed $id)Deletes a stored file.
| Name | Type | Description |
|---|---|---|
$id | mixed | The document identifier, either a string or |
messageStream
messageStream(mixed $id)Gets the file as a PSR-7 Stream.
| Name | Type | Description |
|---|---|---|
$id | mixed | The document identifier, either a string or |
| Type | Description |
|---|---|
StreamInterface | The readable stream |
read
read(mixed $id)Gets a stored file.
| Name | Type | Description |
|---|---|---|
$id | mixed | The document identifier, either a string or |
| Type | Description |
|---|---|
?Tv | The stored file |
readAll
readAll(ConstMap<string,mixed> $criteria)Finds several files by some arbitrary criteria.
| Name | Type | Description |
|---|---|---|
$criteria | ConstMap<string,mixed> | Field to value pairs |
| Type | Description |
|---|---|
Traversable<Tv> | The objects found |
resource
resource(mixed $id)Gets a stream resource for the given ID.
| Name | Type | Description |
|---|---|---|
$id | mixed | The document identifier, either a string or |
| Type | Description |
|---|---|
resource | The stream |
store
store(UploadedFileInterface $file, ConstMap<string,mixed> $metadata)Stores an uploaded file.
You should specify contentType in the metadata Map.
| Name | Type | Description |
|---|---|---|
$file | UploadedFileInterface | The uploaded file |
$metadata | ConstMap<string,mixed> | Any additional fields to persist. At the very least, try to supply |
| Type | Description |
|---|---|
Tk | The document ID of the stored file |
stream
stream(Tv $file, StreamInterface $stream)Efficiently writes the contents of a file to a Stream.
| Name | Type | Description |
|---|---|---|
$file | Tv | The file |
$stream | StreamInterface | The stream |