PHP Class Uploadcare\Api

Mostrar archivo Open project: uploadcare/uploadcare-php Class Usage Examples

Public Properties

Property Type Description
$api_version string Uploadcare rest API version
$cdn_host string Uploadcare CDN host
$cdn_protocol string Uploadcare CDN protocol
$uploader Uploader Uploader instance
$version string Uploadcare library version
$widget Widget Widget instance.

Public Methods

Method Description
__construct ( string $public_key, string $secret_key, string $userAgentName = null, string $cdn_host = null, string $cdn_protocol = null, integer $retry_throttled = null ) Constructor
__preparedRequest ( string $type, string $request_type = 'GET', array $params = [], array $data = [], null $retry_throttled = null ) : object Make request to API.
booleanString ( $bool ) : string Convert boolean to string
copyFile ( string $source, string $target = null ) : File | string Copy file
dateTimeString ( string | DateTime $datetime ) : null | string Convert datetime from string or \DateTime object to ATOM string
getCdnUri ( ) : string Return CDN URI
getFile ( string $uuid_or_url ) : File Get object of File class by id
getFileList ( array $options = [] ) : FileIterator Return an iterator of File objects to work with.
getFilesChunk ( array $options = [], $reverse = false ) : array Get portion of files from server respecting filters
getFilesCount ( array $options = [] ) : mixed Return count of files respecting filters
getGroup ( string $uuid_or_url ) : uploadcare\Group Get group.
getGroupList ( $from = null ) : array Return an array of groups
getPublicKey ( ) : string Return public key
getUserAgent ( ) : string Returns full user agent string
request ( string $method, string $path, array $data = [], array $headers = [] ) : object Run raw request to REST.

Private Methods

Method Description
__getPath ( string $type, array $params = [] ) : string Return path to send request to.
__getQueryString ( array $queryAr = [], string $prefixIfNotEmpty = '' ) : string Convert query array to encoded query string.
__setHeaders ( $ch, array $add_headers = [], array $data = [] ) : void Set all the headers for request and set returntrasfer.
__setRequestType ( $ch, string $type = 'GET' ) : void Set request type.

Method Details

__construct() public method

Constructor
public __construct ( string $public_key, string $secret_key, string $userAgentName = null, string $cdn_host = null, string $cdn_protocol = null, integer $retry_throttled = null )
$public_key string A public key given by Uploadcare.com
$secret_key string A private (secret) key given by Uploadcare.com
$userAgentName string Custom User agent name to report
$cdn_host string CDN Host
$cdn_protocol string CDN Protocol
$retry_throttled integer Retry throttled requests this number of times

__preparedRequest() public method

Throws Exception if not http code 200 was returned. If http code 200 it will parse returned data form request as JSON.
public __preparedRequest ( string $type, string $request_type = 'GET', array $params = [], array $data = [], null $retry_throttled = null ) : object
$type string Construct type. Url will be generated using this params. Options: store
$request_type string Request type. Options: get, post, put, delete.
$params array Additional parameters for requests as array.
$data array Data will be posted like json.
$retry_throttled null
return object

booleanString() public static method

Convert boolean to string
public static booleanString ( $bool ) : string
$bool
return string

copyFile() public method

Copy file
public copyFile ( string $source, string $target = null ) : File | string
$source string CDN URL or file's uuid you need to copy.
$target string Name of custom storage connected to your project. Uploadcare storage is used if target is absent.
return File | string

dateTimeString() public static method

Convert datetime from string or \DateTime object to ATOM string
public static dateTimeString ( string | DateTime $datetime ) : null | string
$datetime string | DateTime
return null | string

getCdnUri() public method

Return CDN URI
public getCdnUri ( ) : string
return string

getFile() public method

Get object of File class by id
public getFile ( string $uuid_or_url ) : File
$uuid_or_url string Uploadcare file UUID or CDN URL
return File

getFileList() public method

This class provides iteration over all uploaded files. You can specify: - $options['from'] - a DateTime object or string from which objects will be iterated; - $options['to'] - a DateTime object or string to which objects will be iterated; - $options['limit'] - a total number of objects to be iterated; If not specified, all available objects are iterated; - $options['request_limit'] - a number of objects to be downloaded per request. - $options['stored'] - True to include only stored files, False to exclude, Null is default, will not exclude anything; - $options['removed'] - True to include only removed files, False to exclude, Null will not exclude anything. The default is False.
public getFileList ( array $options = [] ) : FileIterator
$options array
return FileIterator

getFilesChunk() public method

Get portion of files from server respecting filters
public getFilesChunk ( array $options = [], $reverse = false ) : array
$options array
return array

getFilesCount() public method

Return count of files respecting filters
public getFilesCount ( array $options = [] ) : mixed
$options array
return mixed

getGroup() public method

Get group.
public getGroup ( string $uuid_or_url ) : uploadcare\Group
$uuid_or_url string Uploadcare group UUID or CDN URL
return uploadcare\Group

getGroupList() public method

Return an array of groups
public getGroupList ( $from = null ) : array
$from string
return array

getPublicKey() public method

Return public key
public getPublicKey ( ) : string
return string

getUserAgent() public method

Returns full user agent string
public getUserAgent ( ) : string
return string

request() public method

Run raw request to REST.
public request ( string $method, string $path, array $data = [], array $headers = [] ) : object
$method string Request method: GET, POST, HEAD, OPTIONS, PUT, etc
$path string Path to request
$data array Array of data to send.
$headers array Additional headers.
return object

Property Details

$api_version public_oe property

Uploadcare rest API version
public string $api_version
return string

$cdn_host public_oe property

Uploadcare CDN host
public string $cdn_host
return string

$cdn_protocol public_oe property

Uploadcare CDN protocol
public string $cdn_protocol
return string

$uploader public_oe property

Uploader instance
public Uploader,uploadcare $uploader
return Uploader

$version public_oe property

Uploadcare library version
public string $version
return string

$widget public_oe property

Widget instance.
public Widget,uploadcare $widget
return Widget