Skip to main content
Represents an uploaded file stored in AWS S3 with metadata and utility methods. Provides a structured way to handle file information for files stored in S3, including methods for generating presigned URLs, serialization, and accessing file metadata.
export interface Attachment {
  fileName: string;
  key: string;
  bucket: string;
  region: string;
  endpoint?: string | null;
  suggestedFileName: string;
  fileType?: AttachmentType | null;
  toJSON(): Record<string, string>;
  toDict(): Record<string, string>;
  getS3Key(): string;
  getFilePath(): string;
  getSignedUrl(expiration?: number): Promise<string>;
}

Properties

fileName
string
The name/key of the file in the S3 bucket
key
string
The S3 object key/path
bucket
string
The S3 bucket name where the file is stored
region
string
The AWS region where the S3 bucket is located
endpoint
string
Optional custom S3 endpoint URL. Defaults to undefined for standard AWS S3
suggestedFileName
string
A human-readable filename suggestion for downloads or display
fileType
AttachmentType
The file type of the file

Methods

Returns a JSON-serializable record representation of the file.Returns: Record<string, string>Complete model data including all fields
Converts the file metadata to a record.Returns: Record<string, string>Record with fileName, key, bucket, region, endpoint, suggestedFileName, and fileType
Returns the full S3 URL for the file.Returns: stringComplete S3 URL in format: https://bucket.s3.region.amazonaws.com/filename
Returns the file path/key within the S3 bucket.Returns: stringThe fileName property (S3 object key)
Generates a presigned URL for secure, temporary access to the file.
expiration
any
URL expiration time in seconds. Defaults to 432000 (5 days)
Returns: Promise<string>Presigned URL for downloading the file

Examples

import { uploadFileToS3, Attachment } from "@intuned/browser";
import { BrowserContext, Page } from "playwright";
interface Params {}
export default async function handler(params: Params, page: Page, context: BrowserContext){
  const uploadedFile: Attachment = await uploadFileToS3({
    file: myFile,
    configs: s3Config
  });
  // Access file properties
  console.log(uploadedFile.fileName);
  console.log(uploadedFile.suggestedFileName);
}