VolumeFileType
File type enum.Enumeration Members
Classes
Volume
Module for interacting with E2B volumes. Create aVolume instance to interact with a volume by its ID,
or use the static methods to manage volumes.
Constructors
Parameters
| Parameter | Type | Description |
|---|---|---|
volumeId | string | volume ID. |
name | string | volume name. |
token | string | volume auth token. |
domain? | string | domain for the volume API. |
debug? | boolean | whether to use debug mode. |
proxy? | string | proxy URL for the volume content API. |
Returns
Volume
Properties
Methods
exists()
true if the path exists,
false if it does not (404). Other errors are rethrown.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | string | path to the file or directory. |
opts? | VolumeApiOpts | connection options. |
Returns
Promise<boolean>
true if the path exists, false otherwise.
getInfo()
Parameters
| Parameter | Type | Description |
|---|---|---|
path | string | path to the file or directory. |
opts? | VolumeApiOpts | connection options. |
Returns
Promise<VolumeEntryStat>
information about the entry.
list()
Parameters
| Parameter | Type | Description |
|---|---|---|
path | string | path to the directory. |
opts? | VolumeApiOpts & object | connection options. |
Returns
Promise<VolumeEntryStat[]>
list of entries in the directory.
makeDir()
Parameters
| Parameter | Type | Description |
|---|---|---|
path | string | path to the directory to create. |
opts? | VolumeMetadataOptions & object & VolumeApiOpts | connection options. |
Returns
Promise<VolumeEntryStat>
readFile()
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? | VolumeApiOpts & 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? | VolumeApiOpts & 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? | VolumeApiOpts & 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? | VolumeApiOpts & object | connection options. |
Returns
Promise<ReadableStream<Uint8Array<ArrayBufferLike>>>
file content as ReadableStream
remove()
Parameters
| Parameter | Type | Description |
|---|---|---|
path | string | path to the file or directory to remove. |
opts? | VolumeApiOpts | connection options. |
Returns
Promise<void>
updateMetadata()
Parameters
| Parameter | Type | Description |
|---|---|---|
path | string | path to the file or directory. |
metadata | VolumeMetadataOptions | metadata to update (uid, gid, mode). |
opts? | VolumeApiOpts | connection options. |
Returns
Promise<VolumeEntryStat>
updated entry information.
writeFile()
Parameters
| Parameter | Type | Description |
|---|---|---|
path | string | path to the file. |
data | | string | ArrayBuffer | Blob | ReadableStream<Uint8Array<ArrayBufferLike>> | data to write to the file. Data can be a string, ArrayBuffer, Blob, or ReadableStream. |
opts? | VolumeMetadataOptions & object & VolumeApiOpts | connection options. |
Returns
Promise<VolumeEntryStat>
information about the written file
connect()
Parameters
| Parameter | Type | Description |
|---|---|---|
volumeId | string | volume ID. |
opts? | ConnectionOpts | connection options. |
Returns
Promise<Volume>
Volume instance.
create()
Parameters
| Parameter | Type | Description |
|---|---|---|
name | string | name of the volume. |
opts? | ConnectionOpts | connection options. |
Returns
Promise<Volume>
new Volume instance.
destroy()
Parameters
| Parameter | Type | Description |
|---|---|---|
volumeId | string | volume ID. |
opts? | ConnectionOpts | connection options. |
Returns
Promise<boolean>
getInfo()
Parameters
| Parameter | Type | Description |
|---|---|---|
volumeId | string | volume ID. |
opts? | ConnectionOpts | connection options. |
Returns
Promise<VolumeAndToken>
volume information.
list()
Parameters
| Parameter | Type | Description |
|---|---|---|
opts? | ConnectionOpts | connection options. |
Returns
Promise<VolumeInfo[]>
list of volume information.
VolumeConnectionConfig
Constructors
Parameters
| Parameter | Type |
|---|---|
volume | Volume |
opts? | VolumeApiOpts |
Returns
VolumeConnectionConfig
Properties
Methods
getSignal()
Parameters
| Parameter | Type |
|---|---|
requestTimeoutMs? | number |
signal? | AbortSignal |
Returns
undefined | AbortSignal
Interfaces
VolumeApiOpts
Properties
domain?
Default
E2B_DOMAIN // environment variable ore2b.app
headers?
logger?
Logger interface—for example, console.
proxy?
Example
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.
token?
Default
Type Aliases
VolumeAndToken
Type declaration
| Name | Type | Description |
|---|---|---|
token | string | Volume auth token. |
VolumeEntryStat
Type declaration
| Name | Type | Description |
|---|---|---|
atime | Date | Access time as a Date object. |
ctime | Date | Creation time as a Date object. |
mtime | Date | Modification time as a Date object. |
type | VolumeFileType | File type. |
VolumeInfo
Type declaration
VolumeMetadataOptions
Type declaration
VolumeWriteOptions
Type declaration
| Name | Type | Description |
|---|---|---|
force? | boolean | For makeDir: Create parent directories if they don’t exist. For writeFile: Force overwrite of an existing file. |