Documentation

MultipartStream
in package
implements StreamInterface uses StreamDecoratorTrait

FinalYes

Stream that when read returns bytes for a streaming multipart or multipart/form-data stream.

Table of Contents

Interfaces

StreamInterface
Describes a data stream.

Constants

BOUNDARY_CHARS  : mixed = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJ...

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
addNestedElements()  : void
Recursively expand array contents into multiple form fields.
createElement()  : StreamInterface, 1: array}
deprecateInvalidPartHeaderName()  : void
deprecateInvalidPartHeaderValue()  : void
getHeader()  : string|null
getHeaders()  : string
Get the headers needed before transferring the content of a POST file
isValidBoundary()  : bool
normalizePartHeaders()  : array<string|int, string>

Constants

BOUNDARY_CHARS

private mixed BOUNDARY_CHARS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'()+_,-./:=? "

Properties

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|null $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 any non-array value accepted by Utils::streamFor() (non-string scalar field values are cast to string), or an array for nested expansion. Optional keys include "headers" (associative array of custom headers) and "filename" (string to send as the filename in the part). When "contents" is an array, it is recursively expanded into multiple fields using bracket notation (e.g., name[0][key]). Empty arrays produce no fields. The "filename" and "headers" options cannot be used with array contents.

$boundary : string|null = null

You can optionally provide a specific boundary

Tags
throws
InvalidArgumentException

getMetadata()

public getMetadata([mixed $key = null ]) : mixed
Parameters
$key : mixed = null

isWritable()

Returns whether or not the stream is writable.

public isWritable() : bool
Return values
bool

read()

public read(mixed $length) : string
Parameters
$length : mixed
Return values
string

seek()

public seek(mixed $offset[, mixed $whence = SEEK_SET ]) : void
Parameters
$offset : mixed
$whence : mixed = SEEK_SET

write()

public write(mixed $string) : int
Parameters
$string : mixed
Return values
int

createStream()

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
StreamInterface

addNestedElements()

Recursively expand array contents into multiple form fields.

private addNestedElements(AppendStream $stream, array<string|int, mixed> $contents, string $root) : void
Parameters
$stream : AppendStream
$contents : array<string|int, mixed>
$root : string

createElement()

private createElement(string $name, StreamInterface $stream, string|null $filename, array<string|int, mixed> $headers) : StreamInterface, 1: array}
Parameters
$name : string
$stream : StreamInterface
$filename : string|null
$headers : array<string|int, mixed>
Return values
StreamInterface, 1: array}

deprecateInvalidPartHeaderName()

private static deprecateInvalidPartHeaderName(string $name) : void
Parameters
$name : string

deprecateInvalidPartHeaderValue()

private static deprecateInvalidPartHeaderValue(string $value) : void
Parameters
$value : 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|null

getHeaders()

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>
Return values
string

isValidBoundary()

private static isValidBoundary(string $boundary) : bool
Parameters
$boundary : string
Return values
bool

normalizePartHeaders()

private static normalizePartHeaders(array<string|int, mixed> $headers) : array<string|int, string>
Parameters
$headers : array<string|int, mixed>
Return values
array<string|int, string>
On this page

Search results