Class: FileUploadItem

olympe.ui.std. FileUploadItem

A FileUploadItem represents a file that has been dropped into, or selected from, a FileUpload element. It stores the binary content of the file which can be read as a string for text file or directly as binary ArrayBuffer.


<package> new FileUploadItem(content, name, mimeType, lastModifiedDate, size)

Parameters:
Name Type Description
content ArrayBuffer
name string
mimeType string
lastModifiedDate olympe.df.ODateTime
size number
Implements:
See:

Methods


getContent()

Gets the content of the file.

Returns:

The content.

Type
ArrayBuffer

getContentAsBinary(onSuccess [, onFailure])

Gets the file content as an ArrayBuffer.

Parameters:
Name Type Argument Description
onSuccess function

The function to call on completion with the binary content.

onFailure function <optional>

The function to call on failure with the error reason.

Implements:

getContentAsString(onSuccess [, onFailure])

Retrieves the content of this file and returns it as an UTF-8 string. Note: this method should be used only when the file is a text file.

Parameters:
Name Type Argument Description
onSuccess function

The function to call on completion with the text content.

onFailure function <optional>

The function to call on failure with the error reason.

Implements:

getContentUrl(onSuccess [, onFailure])

Gets the URL that gives direct access to the file content:

  • For files that are external to Olympe, gives the normal URL
  • For the files stored by Olympe, provides a dataURL. Note: The method getUrl returns the url property of this file, without taking into account if the content is directly accessible with this URL (without any authentication process).
Parameters:
Name Type Argument Description
onSuccess function

The function to call on completion with the URL to access to the file content.

onFailure function <optional>

The function to call on failure with the error reason.

Implements:
See:

getFileName()

Gets the file name.

Implements:
Returns:

The name.

Type
olympe.df.POString

getLastModifiedDate()

Gets the last modification time of the file.

Returns:

The modification time.

Type
olympe.df.ODateTime

getMimeType()

Gets the file MIME type.

Implements:
Returns:

The MIME type.

Type
olympe.df.POString

getName()

Gets the file name.

Implements:
Deprecated:
  • Yes
Returns:

The name.

Type
olympe.df.POString

getSize()

Gets the size of the file.

Returns:

The size, in bytes.

Type
number

getUrl()

Gets the URL for this file. Note: Some files won't be accessible via the URL alone because they will need authentication for permission checking. getContentURL will, on the other hand, always return a directly accessible URL.

Implements:
See:
Returns:

The URL.

Type
olympe.df.POString

rename(newName [, callback])

Renames the file. Will pass 'true' to the provided callback once the operation is successfully completed, false otherwise.

Parameters:
Name Type Argument Description
newName string | olympe.df.POString

The new name.

callback function <optional>

Function that will be called on completion.

Implements: