Constructor
new File(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. |
Extends
Methods
(async) deleteFile()
Deletes the file from the user workspace.
Throws:
(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 (folders are not supported).
Parameters:
Name | Type | Default | Description |
---|---|---|---|
target |
string | null | null | The target, see method description for details. |
Throws:
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. |
Throws:
Returns:
- Type
- File