Reference/SDK/TypeScript/Classes

Class: Attachment

Represents an attachment to be uploaded and the associated metadata. Attachment objects can be inserted anywhere in an event, allowing you to log arbitrary file data. The SDK will asynchronously upload the file to object storage and replace the Attachment object with an AttachmentReference.

Constructors

constructor

new Attachment(«destructured»): Attachment

Construct an attachment.

Parameters

NameType
«destructured»AttachmentParams

Returns

Attachment

Methods

data

data(): Promise<Blob>

The attachment contents. This is a lazy value that will read the attachment contents from disk or memory on first access.

Returns

Promise<Blob>


debugInfo

debugInfo(): Record<string, unknown>

A human-readable description for logging and debugging.

Returns

Record<string, unknown>

The debug object. The return type is not stable and may change in a future release.


upload

upload(): Promise<{ error_message?: string ; upload_status: "error" | "done" | "uploading" }>

On first access, (1) reads the attachment from disk if needed, (2) authenticates with the data plane to request a signed URL, (3) uploads to object store, and (4) updates the attachment.

Returns

Promise<{ error_message?: string ; upload_status: "error" | "done" | "uploading" }>

The attachment status.

Properties

reference

Readonly reference: Object

The object that replaces this Attachment at upload time.

Type declaration

NameType
content_typestring
filenamestring
keystring
type"braintrust_attachment"

On this page