sandbox/filesystem
Enumerations
FileType
Sandbox filesystem object type.Enumeration Members
DIR
DIR: "dir"
Filesystem object is a directory.
Defined in
sandbox/filesystem/index.ts:55FILE
FILE: "file"
Filesystem object is a file.
Defined in
sandbox/filesystem/index.ts:51Classes
Filesystem
Module for interacting with the sandbox filesystem.Constructors
new Filesystem()
new Filesystem(transport,envdApi,connectionConfig):Filesystem
Parameters
• transport:Transport
• envdApi: EnvdApiClient
• connectionConfig: ConnectionConfig
Returns
Filesystem
Defined in
sandbox/filesystem/index.ts:104Methods
exists()
exists(Check if a file or a directory exists.path,opts?):Promise<boolean>
Parameters
• 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
Defined in
sandbox/filesystem/index.ts:399list()
list(List entries in a directory.path,opts?):Promise<EntryInfo[]>
Parameters
• path:string
path to the directory.
• opts?: FilesystemRequestOpts
connection options.
Returns
Promise<EntryInfo[]>
list of entries in the sandbox filesystem directory.
Defined in
sandbox/filesystem/index.ts:270makeDir()
makeDir(Create a new directory and all directories along the way if needed on the specified path.path,opts?):Promise<boolean>
Parameters
• 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.
Defined in
sandbox/filesystem/index.ts:308read()
read(path, opts)
read(Read file content as apath,opts?):Promise<string>
string.
You can pass text, bytes, blob, or stream to opts.format to change the return type.
Parameters
• path:string
path to the file.
• opts?: FilesystemRequestOpts & object
connection options.
Returns
Promise<string>
file content as string
Defined in
sandbox/filesystem/index.ts:123read(path, opts)
read(Read file content as apath,opts?):Promise<Uint8Array>
Uint8Array.
You can pass text, bytes, blob, or stream to opts.format to change the return type.
Parameters
• path:string
path to the file.
• opts?: FilesystemRequestOpts & object
connection options.
Returns
Promise<Uint8Array>
file content as Uint8Array
Defined in
sandbox/filesystem/index.ts:138read(path, opts)
read(Read file content as apath,opts?):Promise<Blob>
Blob.
You can pass text, bytes, blob, or stream to opts.format to change the return type.
Parameters
• path:string
path to the file.
• opts?: FilesystemRequestOpts & object
connection options.
Returns
Promise<Blob>
file content as Blob
Defined in
sandbox/filesystem/index.ts:153read(path, opts)
read(Read file content as apath,opts?):Promise<ReadableStream<Uint8Array>>
ReadableStream.
You can pass text, bytes, blob, or stream to opts.format to change the return type.
Parameters
• path:string
path to the file.
• opts?: FilesystemRequestOpts & object
connection options.
Returns
Promise<ReadableStream<Uint8Array>>
file content as ReadableStream
Defined in
sandbox/filesystem/index.ts:168remove()
remove(Remove a file or directory.path,opts?):Promise<void>
Parameters
• path:string
path to a file or directory.
• opts?: FilesystemRequestOpts
connection options.
Returns
Promise<void>
Defined in
sandbox/filesystem/index.ts:377rename()
rename(Rename a file or directory.oldPath,newPath,opts?):Promise<EntryInfo>
Parameters
• 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.
Defined in
sandbox/filesystem/index.ts:339watchDir()
watchDir(Start watching a directory for filesystem events.path,onEvent,opts?):Promise<WatchHandle>
Parameters
• path:string
path to directory to watch.
• onEvent
callback to call when an event in the directory occurs.
• opts?: WatchOpts
connection options.
Returns
Promise<WatchHandle>
WatchHandle object for stopping watching directory.
Defined in
sandbox/filesystem/index.ts:430write()
write(Write content to a file. Writing to a file that doesn’t exist creates the file. Writing to a file that already exists overwrites the file. Writing to a file at path that doesn’t exist creates the necessary directories.path,data,opts?):Promise<EntryInfo>
Parameters
• 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
Defined in
sandbox/filesystem/index.ts:224Interfaces
EntryInfo
Sandbox filesystem object information.Properties
name
name: string
Name of the filesystem object.
Defined in
sandbox/filesystem/index.ts:33path
path: string
Path to the filesystem object.
Defined in
sandbox/filesystem/index.ts:41type?
Type of the filesystem object.optionaltype:FileType
Defined in
sandbox/filesystem/index.ts:37FilesystemRequestOpts
Options for the sandbox filesystem operations.Extended by
WatchOpts
Properties
requestTimeoutMs?
Timeout for requests to the API in milliseconds.optionalrequestTimeoutMs:number
Default
Defined in
connectionConfig.ts:42user?
User to use for the operation in the sandbox. This affects the resolution of relative paths and ownership of the created filesystem objects.optionaluser:Username
Defined in
sandbox/filesystem/index.ts:76WatchOpts
Options for watching a directory.Properties
onExit()?
Callback to call when the watch operation stops.optionalonExit: (err?) =>void|Promise<void>
Parameters
• err?:Error
Returns
void | Promise<void>
Defined in
sandbox/filesystem/index.ts:93requestTimeoutMs?
Timeout for requests to the API in milliseconds.optionalrequestTimeoutMs:number
Default
Defined in
connectionConfig.ts:42timeoutMs?
Timeout for the watch operation in milliseconds. You can passoptionaltimeoutMs:number
0 to disable the timeout.
Default
Defined in
sandbox/filesystem/index.ts:89user?
User to use for the operation in the sandbox. This affects the resolution of relative paths and ownership of the created filesystem objects.optionaluser:Username