FileType
Sandbox filesystem object type.Enumeration Members
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
getInfo()
Parameters
| Parameter | Type | Description |
|---|---|---|
path | string | path to a file or directory. |
opts? | FilesystemRequestOpts | connection options. |
Returns
Promise<EntryInfo>
information about the file or directory like name, type, and path.
list()
Parameters
| Parameter | Type | Description |
|---|---|---|
path | string | path to the directory. |
opts? | FilesystemListOpts | 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()
Call Signature
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? | FilesystemReadOpts & object | connection options. |
Returns
Promise<string>
file content as string
Call Signature
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? | FilesystemReadOpts & object | connection options. |
Returns
Promise<Uint8Array<ArrayBufferLike>>
file content as Uint8Array
Call Signature
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? | FilesystemReadOpts & object | connection options. |
Returns
Promise<Blob>
file content as Blob
Call Signature
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? | FilesystemReadOpts & object | connection options. |
Returns
Promise<ReadableStream<Uint8Array<ArrayBufferLike>>>
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()
Call Signature
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? | FilesystemWriteOpts | connection options. |
Returns
Promise<WriteInfo>
information about the written file
Call Signature
Parameters
| Parameter | Type | Description |
|---|---|---|
files | WriteEntry[] | - |
opts? | FilesystemWriteOpts | connection options. |
Returns
Promise<WriteInfo[]>
information about the written file
writeFiles()
Parameters
| Parameter | Type | Description |
|---|---|---|
files | WriteEntry[] | list of files to write as WriteEntry objects, each containing path and data. |
opts? | FilesystemWriteOpts | connection options. |
Returns
Promise<WriteInfo[]>
information about the written files
Interfaces
EntryInfo
Sandbox filesystem object information.Properties
group
metadata?
user.e2b.* extended
attributes. On writes this reflects the metadata supplied on upload; on
reads (getInfo, list, rename) it reflects any user.e2b.* xattr on
the file, including ones set out-of-band. undefined when none is set.
mode
modifiedTime?
name
owner
path
permissions
size
symlinkTarget?
type?
FilesystemListOpts
Options for the sandbox filesystem operations.Properties
depth?
requestTimeoutMs?
Default
signal?
AbortSignal that can be used to cancel the in-flight request.
When the signal is aborted, the underlying fetch is aborted and the
returned promise rejects with an AbortError.
user?
FilesystemReadOpts
Options for reading files from the sandbox filesystem.Properties
gzip?
requestTimeoutMs?
Default
signal?
AbortSignal that can be used to cancel the in-flight request.
When the signal is aborted, the underlying fetch is aborted and the
returned promise rejects with an AbortError.
user?
FilesystemRequestOpts
Options for the sandbox filesystem operations.Extended by
FilesystemWriteOptsFilesystemReadOptsFilesystemListOptsWatchOpts
Properties
requestTimeoutMs?
Default
AbortSignal that can be used to cancel the in-flight request.
When the signal is aborted, the underlying fetch is aborted and the
returned promise rejects with an AbortError.
FilesystemWriteOpts
Options for writing files to the sandbox filesystem.Properties
gzip?
metadata?
InvalidArgumentError.
The same metadata is applied to every file in a multi-file upload.
Requires envd 0.6.2 or later.
requestTimeoutMs?
Default
signal?
AbortSignal that can be used to cancel the in-flight request.
When the signal is aborted, the underlying fetch is aborted and the
returned promise rejects with an AbortError.
useOctetStream?
application/octet-stream instead of multipart/form-data.
Defaults to false. Requires envd 0.5.7 or later — when not supported by
the sandbox’s envd version, the upload falls back to multipart/form-data.
user?
WatchOpts
Options for watching a directory.Properties
includeEntry?
undefined for events where the
entry no longer exists at the path (e.g. remove or rename-away events).
Requires envd 0.6.3 or later. Watching with this option against an older sandbox
throws a TemplateError.
onExit()?
Parameters
| Parameter | Type |
|---|---|
err? | Error |
Returns
void | Promise<void>
recursive?
requestTimeoutMs?
Default
signal?
AbortSignal that can be used to cancel the in-flight request.
When the signal is aborted, the underlying fetch is aborted and the
returned promise rejects with an AbortError.
timeoutMs?
0 to disable the timeout.
Default
user?
WriteInfo
Sandbox filesystem object information.Extended by
EntryInfo
Properties
metadata?
user.e2b.* extended
attributes. On writes this reflects the metadata supplied on upload; on
reads (getInfo, list, rename) it reflects any user.e2b.* xattr on
the file, including ones set out-of-band. undefined when none is set.
name
path
type?
Type Aliases
WriteEntry
Type declaration
Functions
mapEntryInfo()
EntryInfo to the SDK EntryInfo.
Parameters
| Parameter | Type |
|---|---|
entry | EntryInfo |
Returns
EntryInfo