Documentation

URLInputSource extends InputSource
in package

A local or distant URL input.

Table of Contents

Properties

$url  : string

Methods

__construct()  : mixed
asLocalInputSource()  : BytesInput
Downloads the file from the url, and returns a BytesInput wrapper object for it.
saveToFile()  : void
Downloads the file and saves it to the specified path.
downloadFile()  : string
Downloads the file from the URL.
generateFileName()  : string
Generates a unique filename.
getFileExtension()  : string|null
Attempts to grab a file's extension.

Properties

Methods

asLocalInputSource()

Downloads the file from the url, and returns a BytesInput wrapper object for it.

public asLocalInputSource([string|null $filename = null ][, string|null $username = null ][, string|null $password = null ][, string|null $token = null ][, int $maxRedirects = 3 ]) : BytesInput
Parameters
$filename : string|null = null

Name of the file.

$username : string|null = null

Optional username for credential-based authentication.

$password : string|null = null

Optional password for credential-based authentication.

$token : string|null = null

Optional token for JWT-based authentication.

$maxRedirects : int = 3

Maximum amount of redirects to follow.

Tags
throws
MindeeSourceException

Throws if the file can't be accessed, downloaded or converted to a proper input source.

Return values
BytesInput

saveToFile()

Downloads the file and saves it to the specified path.

public saveToFile(string $path[, string|null $filename = null ][, string|null $username = null ][, string|null $password = null ][, string|null $token = null ][, int $maxRedirects = 3 ]) : void
Parameters
$path : string

Path to save the file.

$filename : string|null = null

Optional name for the saved file.

$username : string|null = null

Optional username for credential-based authentication.

$password : string|null = null

Optional password for credential-based authentication.

$token : string|null = null

Optional token for JWT-based authentication.

$maxRedirects : int = 3

Maximum amount of redirects to follow.

Tags
throws
MindeeSourceException

Throws if the file can't be accessed, downloaded or saved.

downloadFile()

Downloads the file from the URL.

private downloadFile([string|null $username = null ][, string|null $password = null ][, string|null $token = null ][, int $maxRedirects = 3 ]) : string
Parameters
$username : string|null = null

Optional username for credential-based authentication.

$password : string|null = null

Optional password for credential-based authentication.

$token : string|null = null

Optional token for JWT-based authentication.

$maxRedirects : int = 3

Maximum amount of redirects to follow.

Tags
throws
MindeeSourceException

Throws if the file can't be accessed or downloaded.

Return values
string

generateFileName()

Generates a unique filename.

private static generateFileName(string|null $extension) : string
Parameters
$extension : string|null

File extension, defaults to .tmp.

Return values
string

getFileExtension()

Attempts to grab a file's extension.

private static getFileExtension(string|null $filename) : string|null
Parameters
$filename : string|null

Initial file name.

Return values
string|null

        
On this page

Search results