Download the PHP package talk2cerlin/akamai without Composer
On this page you can find all versions of the php package talk2cerlin/akamai. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package akamai
Netstorage API library package for Akamai
This package follows facade design pattern (Click on the link to read more on this).
Features:
- Upload a file to Akamai Netstorage
- List the files and directories of a given directory
- Download a file
- Delete a file
- Rename a file
- Remove a directory (Directory must be empty to remove)
- Create a new directory
- Generate Video Auth token for playback
Sample .env.akamai
AKAMAI_HOST="Your Netstorage Host"
AKAMAI_KEY="Your Netstorage Key"
AKAMAI_KEYNAME="Your Netstorage Key Name"
AKAMAI_VIDEO_TOKEN="Your Video Token"
Explanation:
This package has three facade classes
1) Akamai\Facades\Config
Introduction:
Config
facade is used to load/set the credentials which are used for API requests
Methods:
1) Config::loadFromENV($path, $name);
This method is used to load the credentials from an env
file. This method will try to load all four env variables which are mentioned in the sample .env.akamai
file.
/*
@param: $path - Path of the env file. Default is current working directory.
@param: $name - Name of the env file to load. Default is `.env.akamai`.
@return: Array - Loaded configuration.
@throws: Akamai\Exceptions\DotEnvException.
*/
2) Config::setAkamaiConfig($config)
This method is to set the credentials in runtime. Will be usefull when the credentials are stored in database or any other mode of storage.
/*
@param: $config - Configuration to be updated.
@return: Array - Loaded configuration.
@throws: Akamai\Exceptions\InvalidDataTypeFoundException;
*/
3) Config::getAkamaiConfig()
This method is to get the credentials in runtime.
/*
@return: Array - Loaded configuration.
*/
2) Akamai\Facades\Akamai
Introduction:
Akamai
facade is used to do the basic operations like upload, download etc.
All API operations return responses as an array with fields for "data" and "code".
/*
[
"data" => API response (simple string or xml string),
"code" => API response status code
]
*/
For a list of all possible status codes, see https://control.akamai.com/dl/customers/NS/NS_http_api_FS.pdf
Methods:
1) Akamai::upload($akamai_path, $file_path);
This method is used to upload a file to Akamai.
/*
@param: $akamai_path - File location with file name and extension to which the file should be uploaded. ex: /cpcode/folder/path/file.mp4
@param: $file_path - Path to the file to be written.
@return: Array - ["data" => API response, "code" => API response status code]
*/
2) Akamai::dir($akamai_path);
This method is used to list the files in a particular directory.
/*
@param: $akamai_path - Directory path to be listed. ex: /cpcode/folder/path
@return: Array - ["data" => API response, "code" => API response status code]
*/
3) Akamai::download($akamai_path);
This method is to download a file
/*
@param: $akamai_path - File location with file name and extension. ex: /cpcode/folder/path/file.mp4
@return: Array - ["data" => API response (contents of file on success), "code" => API response status code]
*/
4) Akamai::delete($akamai_path);
This method is to delete a file
/*
@param: $akamai_path - File location with file name and extension. ex: /cpcode/folder/path/file.mp4
@return: Array - ["data" => API response, "code" => API response status code]
*/
5) Akamai::rename($old_akamai_path, $new_akamai_path);
This method is to rename a file
/*
@param: $old_akamai_path - Existing file location with file name and extension. ex: /cpcode/folder/path/file.mp4
@param: $new_akamai_path - Desired file location with file name and extension. ex: /cpcode/new_folder/new_path/new_file.mp4
@return: Array - ["data" => API response, "code" => API response status code]
*/
6) Akamai::rmdir($akamai_path);
This method is to delete a directory. [CAUTION: Directory has to be empty. (ie, list and delete all files individually before performing this API call)].
/*
@param: $akamai_path - Directory path to be deleted. ex: /cpcode/folder/path
@return: Array - ["data" => API response, "code" => API response status code]
*/
7) Akamai::mkdir($akamai_path);
This method is to create a directory.
/*
@param: $akamai_path - Directory path to be added. ex: /cpcode/folder/path
@return: Array - ["data" => API response, "code" => API response status code]
*/
8) Akamai::generateToken($duration, $type);
[DEPRECATED] Please use Token facade to generate video tokens
This method is to generate video authentication token.
/*
@param: $duration - Time to live (ttl) of that token. (In seconds)
@param: $type - It should be `hdnts` or `hdnea`.
@return: String - Final token which has to be appended with the m3u8 request.
*/
3) Akamai\Facades\Token
Introduction:
Token
facade is used to generate video auth tokens.
Methods:
1) Token::generateVideoToken($duration, $type);
This method is to generate video authentication token.
/*
@param: $duration - Time to live (ttl) of that token. (In seconds)
@param: $type - It should be `hdnts` or `hdnea`.
@return: String - Final token which has to be appended with the m3u8 request.
*/
Usage sample
Change Log:
v3.1.0 Thanks to Julian Griggs
- New mkdir and rename functions
v3.0.0 Thanks to Julian Griggs
- Standardization of API
- Refactor
- Document update
- Removed unwanted test
v2.0.1 Thanks to Julian Griggs
- Added missing return statement for
delete
method.
v2.0.0
- New
Token
facade - Code refactor
- Bug fixes
- Deprecated
Akamai::generateToken($duration, $type)
v1.1.1
- Issue fix
- Document update
v1.1.0
- Added video token api for generating tokens for video based on duration.
v1.0.3
- Code optimization
v1.0.2
- Issue fixes
v1.0.1
- Issue fixes
v1.0.0
- Initial version with support for upload, list directory, download, remove directory and delete