Class BeFileHandlerComponent
File upload, save, modify, delete, manage (remote as well). Uses Transaction component.
Data to be passed to save an object with a file:
path temporary file path or URL
name Name of original file
mime_type MIME type, if not set, try to get from file name (@todo)
file_size file size, if URL, try to read remote file size
Exceptions: BEditaFileExistException // File already exists (thrown in creation) BEditaInfoException // File info not readable (access denied or no data) BEditaMIMEException // MIME type not found or not corresponding to object type BEditaURLRxception // URL rules violated BEditaSaveStreamObjException // Error creating/modifying object BEditaDeleteStreamObjException // Error deleting object
If paranoid == false: remote info not loaded ['allow_php_fopen' not necessary]. Mime info should be passed with data for URLs.
File paths saved on DB are relative to $config['mediaRoot']
- Object
- BeFileHandlerComponent
Modifiedby: $LastChangedBy$
Lastmodified:
$LastChangedDate$
$Id$
Located at controllers/components/be_file_handler.php
Methods summary
public
|
|
public
|
|
public
integer
|
#
save( array & $data, $clone = false, $getInfoUrl = true )
Save object $data If $data['id'] modify otherwise create If file is already present, throw an exception. File data: path: local path or URL (.+//:.+) [remote file] if "allow_url_fopen" is not activated, remote file is not accepted name Name of file. Empty if path == URL mime_type MIME type. Empty if path == URL file_size File size. Empty if path == URL |
public
boolean
|
|
public
string
|
|
public
string
|
|
public
integer
|
|
private
integer
|
#
_createFromURL( array & $data, boolean $clone, boolean $getInfoUrl )
Create (or clone) data for file identified by url |
private
mixed
|
|
public
string
|
|
public
integer|false
|
#
hashFileExists( string $hash )
Check if an hash is already present in streams. Return the streams.id if exists, false otherwise |
private
integer
|
|
public
|
|
private
|
#
setApplicationData( array & $data, string $application_name )
Set application data (name, type, label) |
private
|
|
private
array
|
|
private
boolean
|
|
private
boolean
|
|
public
|
|
public
string
|
|
public
mixed
|
|
private
boolean
|
|
public
string
|
|
public
string
|
#
buildNameFromFile( string $filename )
build friendly url name from filename nameFile.ext become name-file.jpg nameFile become name-file |
public
array
|
#
splitFilename( string $filename )
Split file name by dot [to separate file name from file extension] |
Properties summary
public
array
|
$components
|
#
array('Transaction')
|
public
boolean
|
$paranoid
|
#
true
|
public
boolean
|
$validateErrors
|
#
false
|