MultipartStream
in package
implements
StreamInterface
uses
StreamDecoratorTrait
Stream that when read returns bytes for a streaming multipart or multipart/form-data stream.
Table of Contents
Interfaces
- StreamInterface
- Describes a data stream.
Properties
- $boundary : string
- $stream : StreamInterface
Methods
- __call() : mixed
- Allow decorators to implement custom methods
- __construct() : mixed
- __get() : StreamInterface
- Magic method used to create a new stream if streams are not added in the constructor of a decorator (e.g., LazyOpenStream).
- __toString() : string
- close() : void
- detach() : mixed
- eof() : bool
- getBoundary() : string
- getContents() : string
- getMetadata() : mixed
- getSize() : int|null
- isReadable() : bool
- isSeekable() : bool
- isWritable() : bool
- Returns whether or not the stream is writable.
- read() : string
- rewind() : void
- seek() : void
- tell() : int
- write() : int
- createStream() : StreamInterface
- Create the aggregate stream that will be used to upload the POST data
- addElement() : void
- createElement() : StreamInterface, 1: string[]}
- getHeader() : string|null
- getHeaders() : string
- Get the headers needed before transferring the content of a POST file
Properties
$boundary
private
string
$boundary
$stream
private
StreamInterface
$stream
Methods
__call()
Allow decorators to implement custom methods
public
__call(string $method, array<string|int, mixed> $args) : mixed
Parameters
- $method : string
- $args : array<string|int, mixed>
__construct()
public
__construct([array<string|int, mixed> $elements = [] ][, string $boundary = null ]) : mixed
Parameters
- $elements : array<string|int, mixed> = []
-
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 = null
-
You can optionally provide a specific boundary
Tags
__get()
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) : StreamInterface
Parameters
- $name : string
Return values
StreamInterface__toString()
public
__toString() : string
Return values
stringclose()
public
close() : void
detach()
public
detach() : mixed
eof()
public
eof() : bool
Return values
boolgetBoundary()
public
getBoundary() : string
Return values
stringgetContents()
public
getContents() : string
Return values
stringgetMetadata()
public
getMetadata([mixed $key = null ]) : mixed
Parameters
- $key : mixed = null
getSize()
public
getSize() : int|null
Return values
int|nullisReadable()
public
isReadable() : bool
Return values
boolisSeekable()
public
isSeekable() : bool
Return values
boolisWritable()
Returns whether or not the stream is writable.
public
isWritable() : bool
Return values
boolread()
public
read(mixed $length) : string
Parameters
- $length : mixed
Return values
stringrewind()
public
rewind() : void
seek()
public
seek(mixed $offset[, mixed $whence = SEEK_SET ]) : void
Parameters
- $offset : mixed
- $whence : mixed = SEEK_SET
tell()
public
tell() : int
Return values
intwrite()
public
write(mixed $string) : int
Parameters
- $string : mixed
Return values
intcreateStream()
Create the aggregate stream that will be used to upload the POST data
protected
createStream([array<string|int, mixed> $elements = [] ]) : StreamInterface
Parameters
- $elements : array<string|int, mixed> = []
Return values
StreamInterfaceaddElement()
private
addElement(AppendStream $stream, array<string|int, mixed> $element) : void
Parameters
- $stream : AppendStream
- $element : array<string|int, mixed>
createElement()
private
createElement(string $name, StreamInterface $stream, string|null $filename, array<string|int, string> $headers) : StreamInterface, 1: string[]}
Parameters
- $name : string
- $stream : StreamInterface
- $filename : string|null
- $headers : array<string|int, string>
Return values
StreamInterface, 1: string[]}getHeader()
private
static getHeader(array<string|int, string> $headers, string $key) : string|null
Parameters
- $headers : array<string|int, string>
- $key : string
Return values
string|nullgetHeaders()
Get the headers needed before transferring the content of a POST file
private
getHeaders(array<string|int, string> $headers) : string
Parameters
- $headers : array<string|int, string>