Class: File

File(connection, userId, path)

A File on the user workspace.

Constructor

new File(connection, userId, 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.
userId string The user ID.
path string The path to the file, relative to the user workspace and without user ID.
Source:

Extends

Methods

(async) deleteFile()

Deletes the file from the user workspace.
Source:
Throws:
Error

(async) downloadFile(target) → {Stream|Blob|void}

Downloads a file from the user workspace. This method has different behaviour depending on the environment. If the target is set to `null`, returns a stream in a NodeJS environment or a Blob in a browser environment. If a target is specified, writes the downloaded file to the target location on the file system in a NodeJS environment. In a browser environment offers the file for downloading using the specified name (paths not supported).
Parameters:
Name Type Default Description
target string | null null 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
Stream | Blob | 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}

Returns all data in the model.
Overrides:
Source:
Returns:
Type
object

setAll(metadata) → {this}

Converts the data from an API response into data suitable for our JS client models.
Parameters:
Name Type Description
metadata object JSON object originating from an API response.
Overrides:
Source:
Returns:
Returns the object itself.
Type
this

(async) uploadFile(source, statusCallback) → {File}

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 Default Description
source string | object The source, see method description for details.
statusCallback uploadStatusCallback | null null Optionally, a callback that is executed on upload progress updates.
Source:
Throws:
Error
Returns:
Type
File