Stream that when read returns bytes for a streaming multipart or multipart/form-data stream.
- Full name:
\GuzzleHttp\Psr7\MultipartStream
- This class is marked as final and can't be subclassed
- This class implements:
\Psr\Http\Message\StreamInterface
- This class is a Final class
private string $boundary
private \Psr\Http\Message\StreamInterface $stream
public __construct(array $elements = [], string $boundary = null): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$elements |
array | Array of associative arrays, each containing a required "name" key mapping to the form field, name, a required "contents" key mapping to a StreamInterface/resource/string, an optional "headers" associative array of custom headers, and an optional "filename" key mapping to a string to send as the filename in the part. |
$boundary |
string | You can optionally provide a specific boundary |
public getBoundary(): string
Returns whether or not the stream is writable.
public isWritable(): bool
Get the headers needed before transferring the content of a POST file
private getHeaders(array<string,string> $headers): string
Parameters:
Parameter | Type | Description |
---|---|---|
$headers |
array<string,string> |
Create the aggregate stream that will be used to upload the POST data
protected createStream(array $elements = []): \Psr\Http\Message\StreamInterface
Parameters:
Parameter | Type | Description |
---|---|---|
$elements |
array |
private addElement(\GuzzleHttp\Psr7\AppendStream $stream, array $element): void
Parameters:
Parameter | Type | Description |
---|---|---|
$stream |
\GuzzleHttp\Psr7\AppendStream | |
$element |
array |
private createElement(string $name, \Psr\Http\Message\StreamInterface $stream, ?string $filename, array $headers): array
Parameters:
Parameter | Type | Description |
---|---|---|
$name |
string | |
$stream |
\Psr\Http\Message\StreamInterface | |
$filename |
?string | |
$headers |
array |
private getHeader(array $headers, string $key): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$headers |
array | |
$key |
string |
public __construct(\Psr\Http\Message\StreamInterface $stream): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$stream |
\Psr\Http\Message\StreamInterface | Stream to decorate |
Magic method used to create a new stream if streams are not added in the constructor of a decorator (e.g., LazyOpenStream).
public __get(string $name): \Psr\Http\Message\StreamInterface
Parameters:
Parameter | Type | Description |
---|---|---|
$name |
string |
public __toString(): string
public getContents(): string
Allow decorators to implement custom methods
public __call(string $method, array $args): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$method |
string | |
$args |
array |
public close(): void
{@inheritdoc}
public getMetadata(mixed $key = null): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$key |
mixed |
public detach(): mixed
public getSize(): ?int
public eof(): bool
public tell(): int
public isReadable(): bool
public isWritable(): bool
public isSeekable(): bool
public rewind(): void
public seek(mixed $offset, mixed $whence = SEEK_SET): void
Parameters:
Parameter | Type | Description |
---|---|---|
$offset |
mixed | |
$whence |
mixed |
public read(mixed $length): string
Parameters:
Parameter | Type | Description |
---|---|---|
$length |
mixed |
public write(mixed $string): int
Parameters:
Parameter | Type | Description |
---|---|---|
$string |
mixed |
Implement in subclasses to dynamically create streams when requested.
protected createStream(): \Psr\Http\Message\StreamInterface