PHP Class Uploadcare\Uploader

Exibir arquivo Open project: uploadcare/uploadcare-php

Public Methods

Method Description
__construct ( Api $api ) Constructor
createGroup ( array $files ) : uploadcare\Group Create group from array of File objects
fromContent ( string $content, string $mime_type ) : File Upload file from string using mime-type.
fromPath ( string $path, string | boolean $mime_type = false ) : File Upload file from local path.
fromResource ( resource $fp ) : File Upload file from file pointer
fromUrl ( string $url, boolean $check_status = true, integer $timeout = 1, integer $max_attempts = 5 ) : File | string Upload file from url and get File instance
status ( string $token ) : object Check file status.

Private Methods

Method Description
__initRequest ( $type, array $data = null ) : resource Init upload request and return curl resource
__runRequest ( $ch ) : object Run prepared curl request.
__setData ( $ch, array $data = [] ) : void Set data to be posted on request
__setHeaders ( $ch ) : void Set all the headers for request and set return transfer.
__setRequestType ( resource $ch ) : void Set request type for curl resource

Method Details

__construct() public method

Constructor
public __construct ( Api $api )
$api Api

createGroup() public method

Create group from array of File objects
public createGroup ( array $files ) : uploadcare\Group
$files array
return uploadcare\Group

fromContent() public method

Upload file from string using mime-type.
public fromContent ( string $content, string $mime_type ) : File
$content string
$mime_type string
return File

fromPath() public method

Upload file from local path.
public fromPath ( string $path, string | boolean $mime_type = false ) : File
$path string
$mime_type string | boolean
return File

fromResource() public method

Upload file from file pointer
public fromResource ( resource $fp ) : File
$fp resource
return File

fromUrl() public method

Upload file from url and get File instance
public fromUrl ( string $url, boolean $check_status = true, integer $timeout = 1, integer $max_attempts = 5 ) : File | string
$url string An url of file to be uploaded.
$check_status boolean Wait till upload is complete
$timeout integer Wait $timeout seconds between status checks
$max_attempts integer Check status no more than $max_attempts times
return File | string

status() public method

Return array of json data
public status ( string $token ) : object
$token string
return object