Documentation

BinaryPayload
in package

Simple container for a request binary payload.

Tags
author

zozlak

Table of Contents

Properties

$data  : string
Data as a string (not set if data come from a file)
$filename  : string
File name (real or provided by hand)
$mimeType  : string
Mime type of the data.
$path  : string
Path to the data

Methods

__construct()  : mixed
Creates a binary payload object.
attachTo()  : Request
Attaches the data to a given HTTP request.
guzzleMimetype()  : string|null
createFromData()  : void
Initializes the object from the data in string.
createFromFile()  : void
Initializes the object from a file.

Properties

$data

Data as a string (not set if data come from a file)

private string $data

$filename

File name (real or provided by hand)

private string $filename

Methods

__construct()

Creates a binary payload object.

public __construct([string|null $data = null ][, string|null $filePath = null ][, string|null $mimeType = null ]) : mixed
Parameters
$data : string|null = null

data as a string (pass null for creating a payload from a file)

$filePath : string|null = null

path to a file (when creating a payload from a file) or a filename to be stored in the metadata (when creating a payload from string)

$mimeType : string|null = null

mime type of the data; if not provided it will be guessed from the file name and/or data content

attachTo()

Attaches the data to a given HTTP request.

public attachTo(Request $request) : Request
Parameters
$request : Request

PSR-7 request

Return values
Request

guzzleMimetype()

public static guzzleMimetype(string $fileName) : string|null
Parameters
$fileName : string
Return values
string|null

createFromData()

Initializes the object from the data in string.

private createFromData(string $data, string|null $filename, string|null $mimeType) : void
Parameters
$data : string

data

$filename : string|null

file name to be passed to the repository

$mimeType : string|null

mime type

createFromFile()

Initializes the object from a file.

private createFromFile(string $path, string|null $mimeType) : void

Doesn't call fopen() to avoid problem with async requests.

Parameters
$path : string

file path

$mimeType : string|null

mime type (if not provided it will be guessed based on the file name and/or file content)

Tags
throws
RepoLibException

        
On this page

Search results