Interface UploadableInterface
Uploadable Model Interface
Define the methods that a Model must implement
if it should support file upload through API and want to handle it
Methods summary
public
string|false
|
#
apiUpload( File $file, array $options = array() )
Called during the upload action it receives the temporary file
and move it to the wanted location.
Called during the upload action it receives the temporary file
and move it to the wanted location.
$options contains:
- 'fileName' the safe file name that should be used saving file
- 'hashFile' the file hash (md5) that can be used to know if file is already in the system
- 'user' the user is doing upload
Parameters
- $file
- File object instance of temporary file.
- $options
- Additional info about the upload request.
Returns
string|false Path of uploaded file relative to base directory, or false on failure.
|
public
array
|
#
apiUploadTransformData( array $data )
Transform data for uploaded object.
Called from the API when the upload is finalized creating the object type
with file uploaded associated to it.
Transform data for uploaded object.
Called from the API when the upload is finalized creating the object type
with file uploaded associated to it.
$data contains info about a file previously uploaded:
- 'uri' the file url
- 'name' the file name
- 'mime_type' the file mime type
- 'file_size' the file dimension
- 'original_name' the original file name
- 'hash_file' the file hash
It must return an array of object's fields to save
Parameters
- $data
- Uploaded file data.
Returns
array
|
public
array
|
#
apiUploadQuota( array $uploadableObjects, array $user, object $event )
Find quota usage.
Given an array of uploadable object types and a user
it calculates the quota usage and the total amount of
uploaded objects for that user.
The result must be merged with $event->result and returned in the form:
array(
'object_type_name' => array(
'size' => 12345678,
'number' => 256
),
)
This method is intended to be bound to Api.uploadQuota event
triggered for example by ApiUploadComponent .
Parameters
- $uploadableObjects
- Array of uploadable object types.
- $user
- User data.
- $event
- Dispatched event.
Returns
array
|
public
array|false
|
#
apiCreateThumbnail( integer $id, array $thumbConf = array() )
Create the thumbnail for the requested resource (if necessary)
and returns an array containing the the uri of the thumb and the object id refered from thumb.
Create the thumbnail for the requested resource (if necessary)
and returns an array containing the the uri of the thumb and the object id refered from thumb.
Parameters
- $id
- The id of the object you want to create the thumbnail for.
- $thumbConf
- The thumb configuration
Returns
array|false It must return false if the thumb creation fails
else the array must contain the keys id and uri
|