Class: UserFile

UserFile(connection, path)

A File on the user workspace.

Constructor

new UserFile(connection, path)

Creates an object representing a file on the user workspace.

Parameters:
Name Type Description
connection Connection

A Connection object representing an established connection to an openEO back-end.

path string

The path to the file, relative to the user workspace and without user ID.

Source:

Extends

Members

(protected) apiToClientNames :object.<string, string>

Type:
  • object.<string, string>
Overrides:
Source:

(protected) clientToApiNames :object.<string, string>

Type:
  • object.<string, string>
Overrides:
Source:

(protected) connection :Connection

Type:
Overrides:
Source:

(protected) extra :object.<string, *>

Additional (non-standardized) properties received from the API.

Type:
  • object.<string, *>
Overrides:
Source:

(protected) lastRefreshTime :number

Type:
  • number
Overrides:
Source:

(readonly) modified :string

Date and time the file has lastly been modified, formatted as a RFC 3339 date-time.

Type:
  • string
Source:

(readonly) path :string

Path to the file, relative to the user's directory.

Type:
  • string
Source:

(readonly) size :number

File size in bytes as integer.

Type:
  • number
Source:

Methods

(protected) _convertToRequest(parameters) → {object.<string, *>}

Converts the object to a valid objects for API requests.

Parameters:
Name Type Description
parameters object.<string, *>
Overrides:
Source:
Returns:
Type
object.<string, *>

(protected) _supports(feature) → {boolean}

Checks whether a features is supported by the API.

Parameters:
Name Type Description
feature string
Overrides:
Source:
See:
Returns:
Type
boolean

(async) deleteFile()

Deletes the file from the user workspace.

Source:
Throws:
Error

(async) downloadFile(target) → {Promise.<(Array.<string>|void)>}

Downloads a file from the user workspace and saves it.

This method has different behaviour depending on the environment. In a NodeJS environment writes the downloaded file to the target location on the file system. In a browser environment offers the file for downloading using the specified name (folders are not supported).

Parameters:
Name Type Description
target string

The target, see method description for details.

Source:
Throws:
Error
Returns:
  • Return value depends on the target and environment, see method description for details.
Type
Promise.<(Array.<string>|void)>

get(name) → {*}

Get a value from the additional data that is not part of the core model, i.e. from proprietary extensions.

Parameters:
Name Type Description
name string

Name of the property.

Overrides:
Source:
Returns:

The value, which could be of any type.

Type
*

getAll() → {object.<string, *>}

Returns all data in the model.

Overrides:
Source:
Returns:
Type
object.<string, *>

getDataAge() → {number}

Returns the age of the data in seconds.

Overrides:
Source:
Returns:

Age of the data in seconds as integer.

Type
number

(async) retrieveFile() → {Promise.<(Stream.Readable|Blob)>}

Downloads a file from the user workspace into memory.

This method has different behaviour depending on the environment. Returns a stream in a NodeJS environment or a Blob in a browser environment.

Source:
Throws:
Error
Returns:
  • Return value depends on the target and environment, see method description for details.
Type
Promise.<(Stream.Readable|Blob)>

setAll(metadata) → {BaseEntity}

Converts the data from an API response into data suitable for our JS client models.

Parameters:
Name Type Description
metadata object.<string, *>

JSON object originating from an API response.

Overrides:
Source:
Returns:

Returns the object itself.

Type
BaseEntity

toJSON() → {object.<string, *>}

Returns a JSON serializable representation of the data that is API compliant.

Overrides:
Source:
Returns:
Type
object.<string, *>

(async) uploadFile(source, statusCallbacknullable) → {Promise.<UserFile>}

Uploads a file to the user workspace. If a file with the name exists, overwrites it.

This method has different behaviour depending on the environment. In a nodeJS environment the source must be a path to a file as string. In a browser environment the source must be an object from a file upload form.

Parameters:
Name Type Attributes Default Description
source *

The source, see method description for details.

statusCallback uploadStatusCallback <nullable>
null

Optionally, a callback that is executed on upload progress updates.

Source:
Throws:
Error
Returns:
Type
Promise.<UserFile>