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
$url
public
string
$url
The Uniform Resource Locator.
Methods
__construct()
public
__construct(string $url) : mixed
Parameters
- $url : string
-
Input URL.
Tags
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
Return values
BytesInputsaveToFile()
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
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
Return values
stringgenerateFileName()
Generates a unique filename.
private
static generateFileName(string|null $extension) : string
Parameters
- $extension : string|null
-
File extension, defaults to .tmp.
Return values
stringgetFileExtension()
Attempts to grab a file's extension.
private
static getFileExtension(string|null $filename) : string|null
Parameters
- $filename : string|null
-
Initial file name.