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.
The request timeout bounds only the initial handshake. The returned stream
holds a pooled connection until it is fully read, cancelled, errors, or the
idle timeout (opts.streamIdleTimeoutMs) fires—so consume it to the end or
cancel it (opts.signal).
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.
streamIdleTimeoutMs?
format: 'stream') in milliseconds:
abort if no chunk arrives from the server within this window while
reading. It bounds only the wire — a slow or paused consumer never trips
it (a consumer that holds the stream but stops reading is reclaimed
server-side). Defaults to the request timeout (60s); pass 0 to disable.
user?
FilesystemRequestOpts
Options for the sandbox filesystem operations.Extended by
FilesystemWriteOptsFilesystemReadOptsFilesystemListOptsWatchOpts
Properties
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?
FilesystemWriteOpts
Options for writing files to the sandbox filesystem.Properties
gzip?
application/octet-stream upload.
Requires envd 0.5.7 or later — when not supported by the sandbox’s envd
version, the upload falls back to uncompressed multipart/form-data.
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.
Outside the browser, ReadableStream data is then streamed to the sandbox
instead of being buffered in memory.
Defaults to undefined, which uses octet-stream when any entry is a
ReadableStream (so streamed uploads aren’t buffered) and
multipart/form-data otherwise; browsers always use multipart/form-data
since they can’t stream request bodies. 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
allowNetworkMounts?
TemplateError.
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