public
|
#
initialize( Controller $controller, array $settings = array() )
Initialize component (called before Controller::beforeFilter())
Initialize component (called before Controller::beforeFilter())
Parameters
|
public
array
|
#
quota( array $quotaConf = array() )
Set quota configuration and return it.
If it's called without parameter return the current quota configuration.
Set quota configuration and return it.
If it's called without parameter return the current quota configuration.
Replace self::$quota conf with the new one in $quotaConf passed.
If $quotaConf missing of some keys the related value already set are maintained
Parameters
- $quotaConf
- The quota configuration
Returns
array
|
public
string
|
#
upload( string $originalFileName, string $objectType )
Upload a file using local filesystem or delegating to Model::apiUpload() method if exists.
Upload a file using local filesystem or delegating to Model::apiUpload() method if exists.
After the file is moved to the right location
a row in hash_jobs is added with status "pending" and the hash string is returned.
That hash string must be used from client to associate a new object to the file uploaded
Parameters
- $originalFileName
- The target file name
- $objectType
- The object type to which the upload file refers
Returns
string
Throws
|
public
|
#
checkQuota( integer $fileSize )
Given the file size of file to upload
it checks if the upload quota configuration is exceeded.
Given the file size of file to upload
it checks if the upload quota configuration is exceeded.
Parameters
- $fileSize
- The file size of file to upload
|
public
array|false
|
#
quotaUsed( )
Return the upload quota occupied divided by object type.
Return the upload quota occupied divided by object type.
Event triggered:
Api.uploadQuota: pass to listener a list of objects uploadable and the authenticated user
The listener should be calculate the size occupied (in bytes) from all files linked to a specific object type
and the total number of files.
It should be return an array with object types as keys and the above information.
For example:
array(
'image' => array(
'size' => 12345678,
'number' => 256
),
'video' => array(
'size' => 123456789,
'number' => 15
),
)
The listener should be merge its results with $event->result to avoid to delete other results
calculated from another listener.
If the listener returns false or stop the event propagation the method return false.
Returns
array|false It returns false if the quota calculation fails
|
public
File
|
#
source( )
Read from php://input, put the content in a temporary file and return the File instance
Read from php://input, put the content in a temporary file and return the File instance
Returns
File
Throws
BeditaBadRequestException, BeditaInternalErrorException, BeditaLengthRequiredException
|
public
string
|
#
put( File $source, string $targetName )
Copy the source file in a target path obtained starting from $targetName
and returning the target path.
Once the file is successfully copied it is removed.
Copy the source file in a target path obtained starting from $targetName
and returning the target path.
Once the file is successfully copied it is removed.
Parameters
- $source
- The source File instance
- $targetName
- The file target name
Returns
string
Throws
|
protected
string
|
#
generateToken( array $params = array() )
Save an upload token in hash_jobs table and return it.
Save an upload token in hash_jobs table and return it.
Parameters
- $params
- An array of parameters to save in
hash_jobs.params
Returns
string
Throws
|
public
array
|
#
uploadedFileData( string $uploadToken, string $objectType )
Given an upload token it returns the related data
Given an upload token it returns the related data
Parameters
- $uploadToken
- The upload token
- $objectType
- The object type related to the upload operation
Returns
array
|
public
array
|
#
validateToken( string $uploadToken )
Validate an $uploadToken and return data related
Validate an $uploadToken and return data related
Parameters
- $uploadToken
- The upload token to validate
Returns
array
Throws
|
public
boolean
|
#
removeToken( string $uploadToken )
Remove $uploadToken
Parameters
- $uploadToken
- The upload token to remove
Returns
boolean
|