FileType
Sandbox filesystem object type.Enumeration Members
Enumeration Member | Value | Description |
---|---|---|
DIR | "dir" | Filesystem object is a directory. |
FILE | "file" | Filesystem object is a file. |
Classes
Filesystem
Module for interacting with the sandbox filesystem.Constructors
Parameters
Parameter | Type |
---|---|
transport | Transport |
envdApi | EnvdApiClient |
connectionConfig | ConnectionConfig |
Returns
Filesystem
Methods
exists()
Parameters
Parameter | Type | Description |
---|---|---|
path | string | path to a file or a directory |
opts ? | FilesystemRequestOpts | connection options. |
Returns
Promise
<boolean
>
true
if the file or directory exists, false
otherwise
list()
Parameters
Parameter | Type | Description |
---|---|---|
path | string | path to the directory. |
opts ? | FilesystemRequestOpts | connection options. |
Returns
Promise
<EntryInfo
[]>
list of entries in the sandbox filesystem directory.
makeDir()
Parameters
Parameter | Type | Description |
---|---|---|
path | string | path to a new directory. For example ‘/dirA/dirB’ when creating ‘dirB’. |
opts ? | FilesystemRequestOpts | connection options. |
Returns
Promise
<boolean
>
true
if the directory was created, false
if it already exists.
read()
read(path, opts)
string
.
You can pass text
, bytes
, blob
, or stream
to opts.format
to change the return type.
Parameters
Parameter | Type | Description |
---|---|---|
path | string | path to the file. |
opts ? | FilesystemRequestOpts & object | connection options. |
Returns
Promise
<string
>
file content as string
read(path, opts)
Uint8Array
.
You can pass text
, bytes
, blob
, or stream
to opts.format
to change the return type.
Parameters
Parameter | Type | Description |
---|---|---|
path | string | path to the file. |
opts ? | FilesystemRequestOpts & object | connection options. |
Returns
Promise
<Uint8Array
>
file content as Uint8Array
read(path, opts)
Blob
.
You can pass text
, bytes
, blob
, or stream
to opts.format
to change the return type.
Parameters
Parameter | Type | Description |
---|---|---|
path | string | path to the file. |
opts ? | FilesystemRequestOpts & object | connection options. |
Returns
Promise
<Blob
>
file content as Blob
read(path, opts)
ReadableStream
.
You can pass text
, bytes
, blob
, or stream
to opts.format
to change the return type.
Parameters
Parameter | Type | Description |
---|---|---|
path | string | path to the file. |
opts ? | FilesystemRequestOpts & object | connection options. |
Returns
Promise
<ReadableStream
<Uint8Array
>>
file content as ReadableStream
remove()
Parameters
Parameter | Type | Description |
---|---|---|
path | string | path to a file or directory. |
opts ? | FilesystemRequestOpts | connection options. |
Returns
Promise
<void
>
rename()
Parameters
Parameter | Type | Description |
---|---|---|
oldPath | string | path to the file or directory to rename. |
newPath | string | new path for the file or directory. |
opts ? | FilesystemRequestOpts | connection options. |
Returns
Promise
<EntryInfo
>
information about renamed file or directory.
watchDir()
Parameters
Parameter | Type | Description |
---|---|---|
path | string | path to directory to watch. |
onEvent | (event : FilesystemEvent ) => void | Promise <void > | callback to call when an event in the directory occurs. |
opts ? | WatchOpts & object | connection options. |
Returns
Promise
<WatchHandle
>
WatchHandle
object for stopping watching directory.
write()
write(path, data, opts)
Parameters
Parameter | Type | Description |
---|---|---|
path | string | path to file. |
data | string | ArrayBuffer | Blob | ReadableStream <any > | data to write to the file. Data can be a string, ArrayBuffer , Blob , or ReadableStream . |
opts ? | FilesystemRequestOpts | connection options. |
Returns
Promise
<EntryInfo
>
information about the written file
write(files, opts)
Parameters
Parameter | Type |
---|---|
files | WriteEntry [] |
opts ? | FilesystemRequestOpts |
Returns
Promise
<EntryInfo
[]>
Interfaces
EntryInfo
Sandbox filesystem object information.Properties
name
path
type?
FilesystemRequestOpts
Options for the sandbox filesystem operations.Extended by
WatchOpts
Properties
requestTimeoutMs?
Default
user?
WatchOpts
Options for watching a directory.Properties
onExit()?
Parameters
Parameter | Type |
---|---|
err ? | Error |
Returns
void
| Promise
<void
>
recursive?
requestTimeoutMs?
Default
timeoutMs?
0
to disable the timeout.
Default
user?
Type Aliases
WriteEntry
Type declaration
Name | Type |
---|---|
data | string | ArrayBuffer | Blob | ReadableStream |
path | string |