ParseFile
in package
implements
Encodable
Class ParseFile - Representation of a Parse File object.
Tags
Interfaces, Classes and Traits
- Encodable
- Class Encodable - Interface for Parse Classes which provide an encode method.
Table of Contents
- $data : string
- The data.
- $mimeType : string
- The mime type.
- $name : string
- The filename.
- $url : string
- The URL of file data stored on Parse.
- _createFromServer() : ParseFile
- Internal method used when constructing a Parse File from Parse.
- _encode() : array<string|int, mixed>
- Encode to associative array representation.
- createFromData() : ParseFile
- Create a Parse File from data i.e. $file = ParseFile::createFromData('hello world!', 'hi.txt');.
- createFromFile() : ParseFile
- Create a Parse File from the contents of a local file i.e. $file = ParseFile::createFromFile('/tmp/foo.bar', 'foo.bar');.
- delete() : mixed
- Send a REST request to delete the ParseFile.
- getData() : mixed
- Return the data for the file, downloading it if not already present.
- getMimeType() : string|null
- Return the mimeType for the file, if set.
- getName() : string
- Return the name for the file Upon saving to Parse, the name will change to a unique identifier.
- getURL() : string|null
- Return the URL for the file, if saved.
- save() : bool
- Uploads the file contents to Parse, if not saved.
- download() : mixed
- Attempts to download and return the contents of a ParseFile's url
- getMimeTypeForExtension() : string
- Returns the mimetype for a given extension
- upload() : mixed
- Internally uploads the contents of the file to a Parse Server
Properties
$data
The data.
private
string
$data
$mimeType
The mime type.
private
string
$mimeType
$name
The filename.
private
string
$name
$url
The URL of file data stored on Parse.
private
string
$url
Methods
_createFromServer()
Internal method used when constructing a Parse File from Parse.
public
static _createFromServer(string $name, string $url) : ParseFile
Parameters
- $name : string
- $url : string
Return values
ParseFile —_encode()
Encode to associative array representation.
public
_encode() : array<string|int, mixed>
Return values
array<string|int, mixed> —createFromData()
Create a Parse File from data i.e. $file = ParseFile::createFromData('hello world!', 'hi.txt');.
public
static createFromData(mixed $contents, string $name[, string $mimeType = null ]) : ParseFile
Parameters
- $contents : mixed
-
The file contents
- $name : string
-
The file name on Parse, can be used to detect mimeType
- $mimeType : string = null
-
Optional, The mime-type to use when saving the file
Return values
ParseFile —createFromFile()
Create a Parse File from the contents of a local file i.e. $file = ParseFile::createFromFile('/tmp/foo.bar', 'foo.bar');.
public
static createFromFile(string $path, string $name[, string $mimeType = null ]) : ParseFile
Parameters
- $path : string
-
Path to local file
- $name : string
-
Filename to use on Parse, can be used to detect mimeType
- $mimeType : string = null
-
Optional, The mime-type to use when saving the file
Return values
ParseFile —delete()
Send a REST request to delete the ParseFile.
public
delete([bool $useMasterKey = true ]) : mixed
Parameters
- $useMasterKey : bool = true
-
Whether to use the Master Key.
Tags
Return values
mixed —getData()
Return the data for the file, downloading it if not already present.
public
getData() : mixed
Tags
Return values
mixed —getMimeType()
Return the mimeType for the file, if set.
public
getMimeType() : string|null
Return values
string|null —getName()
Return the name for the file Upon saving to Parse, the name will change to a unique identifier.
public
getName() : string
Return values
string —getURL()
Return the URL for the file, if saved.
public
getURL() : string|null
Return values
string|null —save()
Uploads the file contents to Parse, if not saved.
public
save([bool $useMasterKey = false ]) : bool
Parameters
- $useMasterKey : bool = false
-
Whether to use the Master Key.
Return values
bool —download()
Attempts to download and return the contents of a ParseFile's url
private
download() : mixed
Tags
Return values
mixed —getMimeTypeForExtension()
Returns the mimetype for a given extension
private
getMimeTypeForExtension(string $extension) : string
Parameters
- $extension : string
-
Extension to return type for
Return values
string —upload()
Internally uploads the contents of the file to a Parse Server
private
upload([bool $useMasterKey = false ]) : mixed
Parameters
- $useMasterKey : bool = false
-
Whether to use the Master Key.
Tags
Return values
mixed —Result from Parse API Call.