Skip to content
Huey Ly edited this page Aug 11, 2017 · 5 revisions

Table of contents


Class: \Filestack\FilestackClient

FilestackClient client. This is the main object to make functional calls to the Filestack API.

Visibility Function
public __call(mixed $method, mixed $args) : void
Catchall function, throws Filestack Exception if method is not valid
public __construct(string $api_key, \Filestack\FilestackSecurity $security=null, \Filestack\GuzzleHttp\Client $http_client=null, \Filestack\UploadProcessor $upload_processor=null) : void
FilestackClient constructor security settings is turned on one if not passed in
public collage(array $sources, int $width, int $height, array $store_options=array(), string $color='white', string $fit='auto', int $margin=10, bool $auto_rotate=false) : Filestack/Filelink or contents
Set this Filelink's transform_url to include the collage task urls. These are the images that will comprise the other images in the collage. The order in which they appear in the array dictates how the images will be arranged. word or hex value, e.g. ('red' or 'FF0000') images in the collage are manipulated so that the final collage image will match the height and width parameters you set more closely. Using crop will produce a result that is closest to the height and width parameters you set. the images. Range is 1 to 100. rotates all the images in the collage according to their exif orientation data.
public convertAudio(string $resource, string $format, array $options=array(), bool $force=false) : string (uuid of conversion task)
Convert url or filelink handle to another audio format. IMPORTANT: To use this function, you must setup webhooks to notify you when the transcoding has completed. See our online documentation for more details: https://www.filestack.com/docs/audio-transformations convert to. e.g (aac, hls, mp3, m4a, oga) access: public or private Indicates that the file should be stored in a way that allows public access going directly to the underlying file store. For instance, if the file is stored on S3, this will allow the S3 url to be used directly. This has no impact on the ability of users to read from the Filestack file URL. Defaults to 'private'. audio_bitrate: Sets the audio bitrate for the audio file that is generated by the transcoding process. Must be an integer between 0 and 999. audio_channels: Set the number of audio channels for the audio file that is generated by the transcoding process. Can be an integer between 1 and 12. Default is same as source audio. audio_sample_rate: Set the audio sample rate for the audio file that is generated by the transcoding process. Can be an integer between 0 and 99999. Default is 44100. clip_length: Set the length of the audio file that is generated by the transcoding process. Format is hours:minutes:seconds e.g. (00:00:20) clip_offset: Set the point to begin the audio clip from. For example, clip_offset:00:00:10 will start the audio transcode 10 seconds into the source audio file. Format is hours:minutes:seconds, e.g. (00:00:10) container: The bucket or container in the specified file store where the file should end up. extname: Set the file extension for the audio file that is generated by the transcoding process, e.g. ('.mp4', '.webm') filename: Set the filename of the audio file that is generated by the transcoding process. force: (bool) set to true to restart completed or pending audio encoding if a transcoding fails, and you make the same request again location: The custom storage service to store the converted file to, options incude 'S3', 'azure', 'gcs', 'rackspace', and 'dropbox' path: The path to store the file at within the specified file store. For S3, this is the key where the file will be stored at. By default, Filestack stores the file at the root at a unique id, followed by an underscore, followed by the filename, for example "3AB239102DB_myaudio.mp3" title: Set the title in the file metadata. or pending audio encoding if a transcoding fails, and you make the same request again
public convertFile(string $resource, string $filetype, array $options=array()) : \Filestack\Filestack/Filelink
Convert audio file from url or filelink handle to another format. To see which format can be converted, see: https://www.filestack.com/docs/image-transformations/conversion convert the file. e.g (doc, docx, html, jpg, ods, odt, pdf, png, svg, txt, webp) background: Set a background color when converting transparent .png files into other file types. Can be a word or hex value, e.g. ('white' or 'FFFFFF') colorspace: RGB, CMYK or Input By default we convert all the images to the RGB color model in order to be web friendly. However, we have added an option to preserve the original colorspace. This will work for JPEGs and TIFFs. compress: (bool) You can take advantage of Filestack's image compression which utilizes JPEGtran and OptiPNG. The value for this parameter is boolean. If you want to compress your image then the value should be true. Compression is off/false by default. density: (int, 1 to 500). You can adjust the density when converting documents like PowerPoint, PDF, AI and EPS files to image formats like JPG or PNG. This can improve the resolution of the output image. docinfo: (bool) Set this to true to get information about a document, such as the number of pages and the dimensions of the file. page: (int, 1 to 10000) If you are converting a file that contains multiple pages such as PDF or powerpoint file, you can extract a specific page using the page parameter. pageformat: set the page size used for the layout of the resultant document. This parameter can be used when converting the format of one document into PDF, PNG, or JPG. Possible values: 'A3', 'A4', 'A5', 'B4','B5', 'letter', 'legal', 'tabloid' pageorientation: portrait or landscape determine the orientation of the resulting document. This parameter can be used when converting the format of one document into PDF, PNG, or JPG. quality: (int, 1 to 100, or 'input') You can change the quality (and reduce the file size) of JPEG images by using the quality parameter. The quality is set to 100 by default. A quality setting of 80 provides a nice balance between file size reduction and image quality. If the quality is instead set to "input" the image will not be recompressed and the input compression level of the jpg will be used. secure: (bool) This parameter applies to conversions of HTML and SVG sources. When the secure parameter is set to true, the HTML or SVG file will be stripped of any insecure tags (HTML sanitization). Default setting is false. strip: (bool) Set to true to remove any metadata embedded in an image.
public convertVideo(string $resource, string $format, array $options=array(), bool $force=false) : string (uuid of conversion task)
Convert a video file from url or filelink handle to another video format. IMPORTANT: To use this function, you must setup webhooks to notify you when the transcoding has completed. See our online docs for more details: https://www.filestack.com/docs/video-transformations convert to. e.g (aac, h264, h264.hi, hls.variant, hls.variant.audio, m4a, mp3, oga, ogg, ogg.hi, webm, webm.hi) access: public or private Indicates that the file should be stored in a way that allows public access going directly to the underlying file store. For instance, if the file is stored on S3, this will allow the S3 url to be used directly. This has no impact on the ability of users to read from the Filestack file URL. Defaults to 'private'. aspect_mode: set the aspect mode (default: letterbox) 'preserve` - Original size and ratio is preserved. 'constrain' - Aspect ratio is maintained, No black bars are added to the output. 'crop' - Fills frame size and crops the rest 'letterbox' - Adds black bars to defined height 'pad' - Adds black bars to output to match defined frame size audio_bitrate: Sets the audio bitrate for the audio file that is generated by the transcoding process. Must be an integer between 0 and 999. audio_channels: Set the number of audio channels for the audio file that is generated by the transcoding process. Can be an integer between 1 and 12. Default is same as source audio. audio_sample_rate: Set the audio sample rate for the audio file that is generated by the transcoding process. Can be an integer between 0 and 99999. Default is 44100. clip_length: Set the length of the video file that is generated by the transcoding process. Format is hours:minutes:seconds e.g. (00:00:20) clip_offset: Set the point to begin the video clip from. For example, clip_offset:00:00:10 will start the audio transcode 10 seconds into the source audio file. Format is hours:minutes:seconds, e.g. (00:00:10) container: The bucket or container in the specified file store where the file should end up. extname: Set the file extension for the audio file that is generated by the transcoding process, e.g. ('.mp4', '.webm') fps: Specify the frames per second of the video that is generated by the transcoding process. Must be an integer between 1 and 300 Default is to copy the original fps of the source file. filename: Set the filename of the audio file that is generated by the transcoding process. keyframe_interval: Adds a key frame every 250 frames to the video that is generated by the transcoding process. Default is 250. location: The custom storage service to store the converted file to, options incude 'S3', 'azure', 'gcs', 'rackspace', and 'dropbox' path: The path to store the file at within the specified file store. For S3, this is the key where the file will be stored at. By default, Filestack stores the file at the root at a unique id, followed by an underscore, followed by the filename, for example "3AB239102DB_myaudio.mp3" title: Set the title in the file metadata. two_pass: Specify that the transcoding process should do two passes to improve video quality. Defaults to false. width: Set the width in pixels of the video that is generated by the transcoding process. height: Set the height in pixels of the video that is generated by the transcoding process. upscale: Upscale the video resolution to match your profile. Defaults to true. video_bitrate: Specify the video bitrate for the video that is generated by the transcoding process. Must be an integer between 1 and 5000. watermark_bottom: The distance from the bottom of the video frame to place the watermark on the video. (0 to 9999) watermark_left: The distance from the left side of the video frame to place the watermark on the video. (0 to 9999) watermark_right: The distance from the left side of the video frame to place the watermark on the video. (0 to 9999) watermark_left: The distance from the top of the video frame to place the watermark on the video. (0 to 9999) watermark_width: Resize the width of the watermark watermark_height: Resize the height of the watermark watermark_url: The Filestack handle or URL of the image file to use as a watermark on the transcoded video. or pending audio encoding if a transcoding fails, and you make the same request again
public debug(string $resource, array $transform_tasks) : json response
Debug transform tasks
public delete(string $handle) : bool (true = delete success, false = failed)
Delete a file from cloud storage
public download(string $url, string $destination) : bool (true = download success, false = failed)
Download a file, saving it to specified destination be foldername (defaults to stored filename)
public getCdnUrl(mixed $handle) : mixed
Get the cdn url of a filestack file
public getContent(string $url) : string (file content)
Get the content of file
public getConvertTaskInfo(string $conversion_url) : \Filestack\json
Get the info of a conversion task given the conversion url
public getMetaData(string $url, array $fields=array()) : array
Get metadata of a file possible fields are: mimetype, filename, size, width, height, location, path, container, exif, uploaded (timestamp), writable, cloud, source_url
public getSafeForWork(string $handle) : \Filestack\json
Get sfw (safe for work) flag of a filelink
public getTags(string $handle) : \Filestack\json
Get tags of a filelink
public getTransformStr(string $taskname, array $process_attrs) : Transformation object
Return the URL portion of a transformation task
public get_retry_miliseconds(int $retry_num) : int
Get the miliseconds of exponential backoff retry strategy
public isUrl(string $url) : bool
Check if a string is a valid url.
public overwrite(string $filepath, string $handle) : \Filestack\Filestack\Filelink
Overwrite a file in cloud storage
public screenshot(string $url, array/string $store_options=array(), string $agent='desktop', string $mode='all', int $width=1024, int $height=768, int $delay) : \Filestack\Filestack/Filelink
Take a screenshot of a URL width is 1024 by default, but can be set to anywhere between 1 to 1920. The height is 768 by default, but can be set to anywhere between 1 to 1080. capturing the webpage. Sometimes pages take longer to load, so you may need to delay the capture in order to make sure the page is rendered before the screenshot is taken. The delay must be an integer between 0 and 10000.
public sendDebug(string $transform_url, string $api_key, \Filestack\FilestackSecurity $security=null) : json object
Send debug call enabled
public sendDelete(string $handle, string $api_key, \Filestack\FilestackSecurity $security) : bool (true = delete success, false = failed)
Delete a file from cloud storage required for this call
public sendOverwrite(string $resource, string $handle, string $api_key, \Filestack\FilestackSecurity $security) : \Filestack\Filestack\Filelink
Overwrite a file in cloud storage required for this call
public sendTransform(string $resource, array $transform_tasks, \Filestack\FilestackSecurity $security=null) : \Filestack\Filestack\Filelink
Applied array of transformation tasks to handle or external url enabled
public sendVideoConvert(string $resource, array $transform_tasks, \Filestack\FilestackSecurity $security=null, bool $force=false) : string (uuid of conversion task)
Send video_convert request to API enabled
public transform(string $url, array $transform_tasks) : Filestack\Filelink or file content
Applied array of transformation tasks to a url optional attributes per task
public upload(string $filepath, array $options=array()) : Filestack\Filelink or file content
Upload a file to desired cloud service, defaults to Filestack's S3 storage. values are: S3, gcs, azure, rackspace, dropbox filename: explicitly set the filename to store as mimetype: explicitly set the mimetype intelligent: set to true to use the Intelligent Ingestion flow
public uploadUrl(mixed $resource, array $options=array()) : \Filestack\Filestack\Filelink
Upload a url to desired cloud service, defaults to Filestack's S3 storage. Set $options['location'] to specify location, possible values are: S3, gcs, azure, rackspace, dropbox location (string, storage location), filename (string, custom filename), mimetype (string, file mimetype), path (string, path in cloud container), container (string, container in bucket), access (string, public
public zip(array $sources, array $store_options=array()) : Filestack/Filelink or file content
Bundle an array of files into a zip file. This task takes the file or files that are passed in the array and compresses them into a zip file. Sources can be handles, urls, or a mix of both
protected addRequestSourceHeader(mixed $headers) : void
Append source header to request headers array
protected appendData(mixed $data, mixed $name, mixed $value) : void
Append a data item
protected appendPromise(mixed $promises, mixed $method, mixed $url, mixed $to_send) : void
protected createTransformStr(array $transform_tasks) : string
Create the transform parts of the transformation url optional attributes per task
protected createTransformUrl(string $api_key, string $type, \Filestack\sring $resource, string $tasks_str, \Filestack\FilestackSecurity $security=null) : string
Create the transform parts of the transformation url image, audio, video
protected getSourceHeaders() : mixed
Get source header
protected handleResponseCreateFilelink(\Filestack\Http\Message\Response $response) : \Filestack\Filestack\Filelink
Handle a Filestack response and create a filelink object
protected handleResponseDecodeJson(\Filestack\Response $response) : array (decoded json)
Handles a response. decode and return json if 200, throws exception otherwise.
protected insertTransformStr(string $url, string $taskname, array $process_attrs=array()) : Transformation object
Insert a transformation task into existing url
protected sendDownload(string $url, string $destination, \Filestack\FilestackSecurity $security=null) : bool (true = download success, false = failed)
Download a file to specified destination given a url can be a directory name security settings is turned on
protected sendGetContent(string $url, \Filestack\FilestackSecurity $security=null) : string (file content)
Get the content of a file. security settings is turned on
protected sendGetMetaData(mixed $url, array/mixed $fields=array(), \Filestack\FilestackSecurity $security=null) : array
Get the metadata of a remote file. Will only retrieve specific fields if optional fields are passed in values are: mimetype, filename, size, width, height,location, path, container, exif, uploaded (timestamp), writable, cloud, source_url security settings is turned on
protected sendGetSafeForWork(string $handle, \Filestack\FilestackSecurity $security) : \Filestack\json
Get the safe for work (sfw) flag of a filelink. security settings is turned on
protected sendGetTags(string $handle, \Filestack\FilestackSecurity $security) : \Filestack\json
Get the tags of a filelink. security settings is turned on
protected sendRequest(mixed $method, string $url, array $data=array(), array $headers=array()) : void
Send request
protected settlePromises(mixed $promises) : void

Class: \Filestack\FilestackConfig

Filestack config constants, such as base URLs

Visibility Function

Class: \Filestack\FilestackException

A Filestack Excepton

Visibility Function
public __construct(mixed $message, mixed $code, \Filestack\Exception $previous=null) : void
public __toString() : void

This class extends \Exception


Class: \Filestack\FilestackSecurity

Class representing a filestack security object

Visibility Function
public __construct(string $secret, array $options=array()) : void
Filestack Security constructor your dev portal default is 1 hour call: The calls that you allow this policy to make, e.g: convert, exif, pick, read, remove, stat, store, write, writeUrl container: (regex) store must match container that the files will be stored under expiry: (timestamp) epoch_timestamp expire, defaults to 1hr handle: specific file this policy can access maxSize: (number) maximum file size in bytes that can be stored by requests with policy minSize: (number) minimum file size in bytes that can be stored by requests with policy path: (regex) store must match the path that the files will be stored under. url: (regex) subset of external URL domains that are allowed to be image/document sources for processing
public signUrl(string $url) : string (url with policy and signature appended)
Append policy and signature to url
public verify(array $policy, \Filestack\string? $secret) : bool
Verify that a policy is valid
protected createSignature(string $encoded_policy, string $secret) : string (sha256 hashed)
Generate a signature
protected urlsafeB64encode(mixed $string) : void
Helper functions
protected validateOptions(array $options) : bool
Validate options are allowed

Class: \Filestack\HttpStatusCodes

Visibility Function
public static getMessage(mixed $code) : mixed
public static isError(mixed $code) : bool
public static isNetworkError(mixed $code) : bool
public static isServerError(mixed $code) : bool

Class: \Filestack\UploadProcessor

FilestackClient client. This is the main object to make functional calls to the Filestack API.

Visibility Function
public __construct(string $api_key, \Filestack\FilestackSecurity $security=null, \Filestack\GuzzleHttp\Client $http_client=null, bool $intelligent=false) : void
UploadProcessor constructor security settings is turned on one if not passed in
public get_retry_miliseconds(int $retry_num) : int
Get the miliseconds of exponential backoff retry strategy
public intelligenceEnabled(mixed $upload_data) : void
public isUrl(string $url) : bool
Check if a string is a valid url.
public registerUploadTask(string $api_key, string $metadata) : \Filestack\json
Trigger the start of an upload task mimetype, location
public run(string $api_key, string $metadata, array $upload_data) : array['statuscode', 'json']
Run upload process, including splitting up the file and sending parts concurrently in chunks. mimetype, location call: uri, region, upload_id
public sendDelete(string $handle, string $api_key, \Filestack\FilestackSecurity $security) : bool (true = delete success, false = failed)
Delete a file from cloud storage required for this call
public sendOverwrite(string $resource, string $handle, string $api_key, \Filestack\FilestackSecurity $security) : \Filestack\Filestack\Filelink
Overwrite a file in cloud storage required for this call
public setIntelligent(mixed $intelligent) : void
protected addRequestSourceHeader(mixed $headers) : void
Append source header to request headers array
protected appendData(mixed $data, mixed $name, mixed $value) : void
Append a data item
protected appendPromise(mixed $promises, mixed $method, mixed $url, mixed $to_send) : void
protected appendSecurity(mixed $data) : void
Append security params
protected buildChunkData(mixed $part, mixed $chunk_data) : void
Create data multipart data for multipart upload api request
protected buildCommitData(mixed $part) : void
protected commitPart(object $part) : int status_code
All chunks of this part has been uploaded. We have to call commit to let the uploader API knows.
protected createParts(string $api_key, array $metadata, array $upload_data) : Filestack/Filelink or file content
Take a file and separate it into parts, creating an array of parts to process. mimetype, location call: uri, region, upload_id
protected getChunkContent(mixed $filepath, mixed $seek_point, mixed $chunk_size) : mixed
Get a chunk from a file given starting seek point.
protected getSourceHeaders() : mixed
Get source header
protected handleResponseCreateFilelink(\Filestack\Http\Message\Response $response) : \Filestack\Filestack\Filelink
Handle a Filestack response and create a filelink object
protected handleResponseDecodeJson(\Filestack\Response $response) : array (decoded json)
Handles a response. decode and return json if 200, throws exception otherwise.
protected handleS3PromisesResult(mixed $s3_results) : void
Handle results of promises after async calls
protected multipartGetTags(mixed $part_num, mixed $s3_results, mixed $parts_etags) : void
Parse results of s3 calls and append to parts_etags array
protected processChunks(object $part, array $chunks) : Promises to send Asyncronously to s3
Process the chunks of a part the file to server.
protected processParts(array $parts) : \Filestack\json
Process the parts of the file to server.
protected registerComplete(string $api_key, string $parts_etags, array $upload_data, string $metadata) : \Filestack\json
Trigger the end of an upload task e.g. '1:etag_1;2:etag_2;3:etag_3 call: uri, region, upload_id filesize, mimetype, location
protected sendDownload(string $url, string $destination, \Filestack\FilestackSecurity $security=null) : bool (true = download success, false = failed)
Download a file to specified destination given a url can be a directory name security settings is turned on
protected sendGetContent(string $url, \Filestack\FilestackSecurity $security=null) : string (file content)
Get the content of a file. security settings is turned on
protected sendGetMetaData(mixed $url, array/mixed $fields=array(), \Filestack\FilestackSecurity $security=null) : array
Get the metadata of a remote file. Will only retrieve specific fields if optional fields are passed in values are: mimetype, filename, size, width, height,location, path, container, exif, uploaded (timestamp), writable, cloud, source_url security settings is turned on
protected sendGetSafeForWork(string $handle, \Filestack\FilestackSecurity $security) : \Filestack\json
Get the safe for work (sfw) flag of a filelink. security settings is turned on
protected sendGetTags(string $handle, \Filestack\FilestackSecurity $security) : \Filestack\json
Get the tags of a filelink. security settings is turned on
protected sendRequest(mixed $method, string $url, array $data=array(), array $headers=array()) : void
Send request
protected settlePromises(mixed $promises) : void
protected uploadChunkToS3(string $url, array $headers, \Filestack\binary $chunk) : int status_code
Upload a chunk of data to S3
Clone this wiki locally