Reference/SDK/TypeScript/Classes

Class: ReadonlyAttachment

A readonly alternative to Attachment, which can be used for fetching already-uploaded Attachments.

Constructors

constructor

new ReadonlyAttachment(reference, state?): ReadonlyAttachment

Construct a ReadonlyAttachment.

Parameters

NameTypeDescription
referenceObjectThe AttachmentReference that should be read by the ReadonlyAttachment object.
reference.content_typestring-
reference.filenamestring-
reference.keystring-
reference.type"braintrust_attachment"-
state?BraintrustState(Optional) For internal use.

Returns

ReadonlyAttachment

The new ReadonlyAttachment object.

Methods

data

data(): Promise<Blob>

The attachment contents. This is a lazy value that will read the attachment contents from the object store on first access.

Returns

Promise<Blob>


status

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

Fetch the attachment upload status. This will re-fetch the status each time in case it changes over time.

Returns

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

Properties

reference

Readonly reference: Object

Attachment metadata.

Type declaration

NameType
content_typestring
filenamestring
keystring
type"braintrust_attachment"

On this page