Scripting API / core/FileApi
core/FileApi
Modules
| Module | Description |
|---|---|
| External | - |
Classes
FileApi
Methods
create()
create(
options):Promise<number>
Creates a new File.
Parameters
| Parameter | Type | Description |
|---|---|---|
options |
FileCreateOptions |
Options to create the File. |
Returns
Promise<number>
delete()
delete(
id):Promise<void>
Deletes a File.
Parameters
| Parameter | Type | Description |
|---|---|---|
id |
number |
The id of the File to delete. |
Returns
Promise<void>
download()
download(
id,options?):Promise<void>
Downloads the given file to the user's device.
This function must be triggered via user interaction (e.g. click) or it will throw an error. The download action must occur within ~5 seconds of the user interaction.
Parameters
| Parameter | Type | Description |
|---|---|---|
id |
number |
The id of the File to download. |
options? |
FileDownloadOptions |
Options to download the File. |
Returns
Promise<void>
downloadRawFile()
downloadRawFile(
options):Promise<void>
Downloads a file directly without uploading it to GS.
This function must be triggered via user interaction (e.g. click) or it will throw an error. The download action must occur within ~5 seconds of the user interaction.
Parameters
| Parameter | Type | Description |
|---|---|---|
options |
FileDownloadRawOptions |
Options to download the File. |
Returns
Promise<void>
getInfo()
getInfo(
id):Promise<SingleFile>
Retrieves information for an existing File. Throws an error if the File does not exist.
Parameters
| Parameter | Type | Description |
|---|---|---|
id |
number |
The id of the File to retrieve. |
Returns
Promise<SingleFile>
openFileDialog()
openFileDialog():
Promise<FileContents>
Opens a local file picker to allow the user to choose a file.
Returns
Promise<FileContents>
The contents of the file chosen by the user. All properties will be undefined if the user cancels the overlay.
read()
read(
id):Promise<Blob>
Retrieves the contents of an existing File. Throws an error if the File does not exist.
Parameters
| Parameter | Type | Description |
|---|---|---|
id |
number |
The id of the File to retrieve. |
Returns
Promise<Blob>
The contents of the File as a Blob.
update()
update(
id,options):Promise<void>
Updates a File.
Parameters
| Parameter | Type | Description |
|---|---|---|
id |
number |
The id of the File to update. |
options |
FileUpdateOptions |
Options to update the File. |
Returns
Promise<void>