new MediaFile(file, endpoint)
Interface for Media Resource
Parameters:
Name | Type | Description |
---|---|---|
file |
string | Object | File | A media resource file |
endpoint |
string | REST API endpoint base |
Example
// In case backend returns content_type & name metadata var file = { file: '/media/<ID>', content_type: 'image/png', name: 'media.png' }; var endpoint = 'http://tests.org/api/2/'; var media = new MediaFile(endpoint, file); console.log(media.$isImage) // true console.log(media.$isAudio) // false console.log(media.$isVideo) // false console.log(media.$uri) // http://tests.org/api/2/media/<ID>'
Methods
-
<static> MediaFile#cleanedData()
-
Return cleaned data for saving process Only
File
type are returned as Eve does not understand ObjectReturns:
Selected File instance or null
- Type
- File | null
-
<static> MediaFile#getInfo()
-
Get MediaFile information
Returns:
A Proxy File Object
- Type
- Object
Example
// Below properties returned by `getInfo()` var returnedMediaFileProps = { file: this.$file, name: this.$name, type: this.$type, lastModified: this.$lastModified, lastModifiedDate: this.$lastModifiedDate };
-
<static> MediaFile#load(file)
-
Load given file and compute matching URI according to media type
Parameters:
Name Type Description file
string | Object | File A media resource file
Returns:
Asynchronous call
- Type
- Promise
-
<static> MediaFile#loadURI()
-
Load asynchronously the file URI.abbrev
- To Do:
-
- Fix Audio & Video type display
Returns:
Asynchronous call
- Type
- Promise
-
<static> MediaFile#setFile(file)
-
Set given file
Parameters:
Name Type Description file
string | Object | File A media resource file
Returns:
this
-
<static> MediaFile#toString()
-
MediaFile string representation
Format: (this.$name, this.$type)
- To Do:
-
- Fix Media served as a base64 string
Returns:
MediaFile string representation
- Type
- string