Methods summary
public
|
#
__construct( string $name, mixed $data = null, string $mimeType = null )
Initialize file
Parameters
- $name
- File base name
- $data
- (optional) File content
- $mimeType
- (optional) Mime type
|
public static
LeanCloud\File
|
#
createWithUrl( string $name, string $url, string $mimeType = null )
Create file with public external URL
Create file with public external URL
Parameters
- $name
- File base name
- $url
- Public URL
- $mimeType
- (optional)
Returns
|
public static
LeanCloud\File
|
#
createWithData( string $name, string $data, string $mimeType = null )
Create file with raw data
Create file with raw data
Parameters
- $name
- File name
- $data
- File content
- $mimeType
Returns
|
public static
LeanCloud\File
|
#
createWithLocalFile( string $filepath, string $mimeType = null, string $name = null )
Create file from disk
Parameters
- $filepath
- Absolute file path
- $mimeType
- E.g. "image/png"
- $name
- Name of file
Returns
Throws
RuntimeException
|
public
mixed
|
#
get( string $key )
Get file attribute
Parameters
Returns
mixed
|
public
string
|
#
getName( )
Get name of file
Returns
string
|
public
string
|
#
getKey( )
Get key of file
Returns
string
|
public
LeanCloud\File
|
|
public
string
|
|
public
DateTime
|
|
public
DateTime
|
|
public
string
|
|
public
string
|
#
getUrl( )
Get file url
Returns
string
|
public
string
|
#
getThumbUrl( float|integer $width, float|integer $height, float|integer $quality = 100, boolean $scaleToFit = true, string $format = "png" )
Get thumbnail URL
It returns a URL that could be used to display file thumbnail on
client. The thumbnail will be generated on-the-fly when request
arrives.
Parameters
- $width
- Image width
- $height
- Image height
- $quality
- Image quality factor between 0 ~ 100
- $scaleToFit
- Scale to fit, or cut to fit
- $format
- Image format: gif, png, webp etc.
Returns
string
|
public
integer
|
#
getSize( )
Get file size
Returns
integer
|
public
string|null
|
#
getOwnerId( )
Get id of uploaded user
Returns
string|null
|
public
LeanCloud\File
|
#
setMeta( string $key, miexed $val )
Set meta data
Parameters
Returns
|
public
mixed
|
#
getMeta( string $key = null )
Get meta data
It returns all metaData if key is null
Parameters
Returns
mixed
|
public
|
#
mergeAfterSave( array $data )
Merge server response after save
Merge server response after save
Parameters
- $data
- JSON decoded response
|
public
|
#
mergeAfterFetch( array $data )
Merge server response after fetch
Merge server response after fetch
Parameters
- $data
- JSON decoded response
|
public
boolean
|
#
isDirty( )
If there are unsaved changes.
If there are unsaved changes.
Returns
boolean
|
public
|
#
save( )
Save file on the cloud
Throws
|
public static
LeanCloud\File
|
#
fetch( $objectId )
Fetch file object by id
Note it fetches descriptive data from LeanCloud, but not file content.
The content should be fetched from file URL.
Returns
|
public
|
#
destroy( )
Delete file on cloud
Throws
|
public
array
|
#
encode( )
Encode to JSON representation
Encode to JSON representation
Returns
array
|