Skip to main content

FileType

Sandbox filesystem object type.

Enumeration Members

Classes

Filesystem

Module for interacting with the sandbox filesystem.

Constructors

Parameters
Returns
Filesystem

Methods

exists()

Check if a file or a directory exists.
Parameters
Returns
Promise<boolean> true if the file or directory exists, false otherwise

getInfo()

Get information about a file or directory.
Parameters
Returns
Promise<EntryInfo> information about the file or directory like name, type, and path.

list()

List entries in a directory.
Parameters
Returns
Promise<EntryInfo[]> list of entries in the sandbox filesystem directory.

makeDir()

Create a new directory and all directories along the way if needed on the specified path.
Parameters
Returns
Promise<boolean> true if the directory was created, false if it already exists.

read()

Call Signature
Read file content as a string. You can pass text, bytes, blob, or stream to opts.format to change the return type.
Parameters
Returns
Promise<string> file content as string
Call Signature
Read file content as a Uint8Array. You can pass text, bytes, blob, or stream to opts.format to change the return type.
Parameters
Returns
Promise<Uint8Array<ArrayBufferLike>> file content as Uint8Array
Call Signature
Read file content as a Blob. You can pass text, bytes, blob, or stream to opts.format to change the return type.
Parameters
Returns
Promise<Blob> file content as Blob
Call Signature
Read file content as a ReadableStream. You can pass text, bytes, blob, or stream to opts.format to change the return type.
Parameters
Returns
Promise<ReadableStream<Uint8Array<ArrayBufferLike>>> file content as ReadableStream

remove()

Remove a file or directory.
Parameters
Returns
Promise<void>

rename()

Rename a file or directory.
Parameters
Returns
Promise<EntryInfo> information about renamed file or directory.

watchDir()

Start watching a directory for filesystem events.
Parameters
Returns
Promise<WatchHandle> WatchHandle object for stopping watching directory.

write()

Call Signature
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.
Parameters
Returns
Promise<WriteInfo> information about the written file
Call Signature
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.
Parameters
Returns
Promise<WriteInfo[]> information about the written file

writeFiles()

Write multiple files. 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.
Parameters
Returns
Promise<WriteInfo[]> information about the written files

Interfaces

EntryInfo

Sandbox filesystem object information.

Properties

group

Group owner of the filesystem object.

metadata?

User-defined metadata stored on the file as 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

File mode and permission bits.

modifiedTime?

Last modification time of the filesystem object.

name

Name of the filesystem object.

owner

Owner of the filesystem object.

path

Path to the filesystem object.

permissions

String representation of file permissions (e.g. ‘rwxr-xr-x’).

size

Size of the filesystem object in bytes.

symlinkTarget?

If the filesystem object is a symlink, this is the target of the symlink.

type?

Type of the filesystem object.

FilesystemListOpts

Options for the sandbox filesystem operations.

Properties

depth?

Depth of the directory to list.

requestTimeoutMs?

Timeout for requests to the API in milliseconds.
Default

signal?

An optional 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?

User to use for the operation in the sandbox. This affects the resolution of relative paths and ownership of the created filesystem objects.

FilesystemReadOpts

Options for reading files from the sandbox filesystem.

Properties

gzip?

When true, the download will request gzip-encoded responses.

requestTimeoutMs?

Timeout for requests to the API in milliseconds.
Default

signal?

An optional 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?

User to use for the operation in the sandbox. This affects the resolution of relative paths and ownership of the created filesystem objects.

FilesystemRequestOpts

Options for the sandbox filesystem operations.

Extended by

  • FilesystemWriteOpts
  • FilesystemReadOpts
  • FilesystemListOpts
  • WatchOpts

Properties

requestTimeoutMs?

Timeout for requests to the API in milliseconds.
Default
An optional 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 to use for the operation in the sandbox. This affects the resolution of relative paths and ownership of the created filesystem objects.

FilesystemWriteOpts

Options for writing files to the sandbox filesystem.

Properties

gzip?

When true, the upload will be gzip-compressed.

metadata?

User-defined metadata to persist on the uploaded file(s) as extended attributes. Keys are lowercased by the sandbox, so they may differ in case when read back. Invalid keys or values throw an InvalidArgumentError. The same metadata is applied to every file in a multi-file upload. Requires envd 0.6.2 or later.

requestTimeoutMs?

Timeout for requests to the API in milliseconds.
Default

signal?

An optional 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?

When true, the upload uses 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?

User to use for the operation in the sandbox. This affects the resolution of relative paths and ownership of the created filesystem objects.

WatchOpts

Options for watching a directory.

Properties

includeEntry?

Include the EntryInfo of the affected entry in each FilesystemEvent. The entry is populated best-effort and may be 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()?

Callback to call when the watch operation stops.
Parameters
Returns
void | Promise<void>

recursive?

Watch the directory recursively

requestTimeoutMs?

Timeout for requests to the API in milliseconds.
Default

signal?

An optional 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?

Timeout for the watch operation in milliseconds. You can pass 0 to disable the timeout.
Default

user?

User to use for the operation in the sandbox. This affects the resolution of relative paths and ownership of the created filesystem objects.

WriteInfo

Sandbox filesystem object information.

Extended by

  • EntryInfo

Properties

metadata?

User-defined metadata stored on the file as 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

Name of the filesystem object.

path

Path to the filesystem object.

type?

Type of the filesystem object.

Type Aliases

WriteEntry

Type declaration

Functions

mapEntryInfo()

Map a protobuf EntryInfo to the SDK EntryInfo.

Parameters

Returns

EntryInfo