DataFileDownloader
in package
Downloads the data file from a provided URL.
Table of Contents
Constants
- XMSG_DOWNLOAD_ERROR = "Error downloading data file due to: %s. Please check if the licence key and data file url is valid and correct respectively."
- XMSG_DOWNLOAD_URL_ERROR = "Please check data file url is a valid url."
- XMSG_ERROR_SAVING_DATA_FILE = "Error saving data file. Please check you have write permissions to: %s"
- XMSG_MD5_VALIDATION_FAILED = "Data file MD5 validation failed. Header validated was: %s."
- XMSG_UNSUPPORTED_CONTENT_TYPE = "Content type %s is not supported. The following content types are supported: %s. Note: Zip content type supported only when zip extension is installed."
Properties
- $dataFile : mixed
Methods
- __construct() : mixed
- downloadDataFile() : bool
- Downloads the data file and performs MD5 validation if configured to do so.
- decompressDataStream() : bool
- Decompress the data if necessary.
- getHttpOptions() : array<string|int, array<string|int, mixed>>
- Prepare the http context options.
- parseHeaders() : array<string|int, mixed>
- Parse response header.
- saveDataFile() : bool
- Saves the data file to a temporary file path. This file will be persisted to a permanent location if it is loaded into the API successfully.
- validateMd5() : mixed
- Validate the response 'content-md5' header with the downloaded stream md5
Constants
XMSG_DOWNLOAD_ERROR
public
mixed
XMSG_DOWNLOAD_ERROR
= "Error downloading data file due to: %s. Please check if the licence key and data file url is valid and correct respectively."
XMSG_DOWNLOAD_URL_ERROR
public
mixed
XMSG_DOWNLOAD_URL_ERROR
= "Please check data file url is a valid url."
XMSG_ERROR_SAVING_DATA_FILE
public
mixed
XMSG_ERROR_SAVING_DATA_FILE
= "Error saving data file. Please check you have write permissions to: %s"
XMSG_MD5_VALIDATION_FAILED
public
mixed
XMSG_MD5_VALIDATION_FAILED
= "Data file MD5 validation failed. Header validated was: %s."
XMSG_UNSUPPORTED_CONTENT_TYPE
public
mixed
XMSG_UNSUPPORTED_CONTENT_TYPE
= "Content type %s is not supported. The following content types are supported: %s. Note: Zip content type supported only when zip extension is installed."
Properties
$dataFile
private
mixed
$dataFile
Methods
__construct()
public
__construct(mixed $dataFile) : mixed
Parameters
- $dataFile : mixed
downloadDataFile()
Downloads the data file and performs MD5 validation if configured to do so.
public
downloadDataFile( $url) : bool
Parameters
Tags
Return values
booldecompressDataStream()
Decompress the data if necessary.
private
decompressDataStream( $content_type) : bool
Parameters
Tags
Return values
boolgetHttpOptions()
Prepare the http context options.
private
getHttpOptions() : array<string|int, array<string|int, mixed>>
Return values
array<string|int, array<string|int, mixed>>parseHeaders()
Parse response header.
private
parseHeaders( $rawHeaders) : array<string|int, mixed>
Parameters
Return values
array<string|int, mixed>saveDataFile()
Saves the data file to a temporary file path. This file will be persisted to a permanent location if it is loaded into the API successfully.
private
saveDataFile( $inputStream, $content_type) : bool
Parameters
Tags
Return values
boolvalidateMd5()
Validate the response 'content-md5' header with the downloaded stream md5
private
validateMd5( $headerMd5, $inputStream) : mixed