PHP Класс Uploadcare\Api

Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$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.

Открытые методы

Метод Описание
__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.

Приватные методы

Метод Описание
__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.

Описание методов

__construct() публичный Метод

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() публичный Метод

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
Результат object

booleanString() публичный статический Метод

Convert boolean to string
public static booleanString ( $bool ) : string
$bool
Результат string

copyFile() публичный Метод

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.
Результат File | string

dateTimeString() публичный статический Метод

Convert datetime from string or \DateTime object to ATOM string
public static dateTimeString ( string | DateTime $datetime ) : null | string
$datetime string | DateTime
Результат null | string

getCdnUri() публичный Метод

Return CDN URI
public getCdnUri ( ) : string
Результат string

getFile() публичный Метод

Get object of File class by id
public getFile ( string $uuid_or_url ) : File
$uuid_or_url string Uploadcare file UUID or CDN URL
Результат File

getFileList() публичный Метод

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
Результат FileIterator

getFilesChunk() публичный Метод

Get portion of files from server respecting filters
public getFilesChunk ( array $options = [], $reverse = false ) : array
$options array
Результат array

getFilesCount() публичный Метод

Return count of files respecting filters
public getFilesCount ( array $options = [] ) : mixed
$options array
Результат mixed

getGroup() публичный Метод

Get group.
public getGroup ( string $uuid_or_url ) : uploadcare\Group
$uuid_or_url string Uploadcare group UUID or CDN URL
Результат uploadcare\Group

getGroupList() публичный Метод

Return an array of groups
public getGroupList ( $from = null ) : array
$from string
Результат array

getPublicKey() публичный Метод

Return public key
public getPublicKey ( ) : string
Результат string

getUserAgent() публичный Метод

Returns full user agent string
public getUserAgent ( ) : string
Результат string

request() публичный Метод

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.
Результат object

Описание свойств

$api_version публичное свойство

Uploadcare rest API version
public string $api_version
Результат string

$cdn_host публичное свойство

Uploadcare CDN host
public string $cdn_host
Результат string

$cdn_protocol публичное свойство

Uploadcare CDN protocol
public string $cdn_protocol
Результат string

$uploader публичное свойство

Uploader instance
public Uploader,uploadcare $uploader
Результат Uploader

$version публичное свойство

Uploadcare library version
public string $version
Результат string

$widget публичное свойство

Widget instance.
public Widget,uploadcare $widget
Результат Widget