> ## Documentation Index
> Fetch the complete documentation index at: https://intunedhq.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Attachment

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.

```typescript theme={null}
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

> [accordion] toJSON
>
> Returns a JSON-serializable record representation of the file.
>
> **Returns:** `Record<string, string>`
>
> Complete model data including all fields

> [accordion] toDict
>
> Converts the file metadata to a record.
>
> **Returns:** `Record<string, string>`
>
> Record with fileName, key, bucket, region, endpoint, suggestedFileName, and fileType

> [accordion] getS3Key
>
> Returns the full S3 URL for the file.
>
> **Returns:** `string`
>
> Complete S3 URL in format: [https://bucket.s3.region.amazonaws.com/filename](https://bucket.s3.region.amazonaws.com/filename)

> [accordion] getFilePath
>
> Returns the file path/key within the S3 bucket.
>
> **Returns:** `string`
>
> The fileName property (S3 object key)

> [accordion] getSignedUrl
>
> 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

```typescript Basic Usage theme={null}
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);
}
```

```typescript Working with Presigned URLs theme={null}
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
  });
  // Generate a presigned URL for temporary access
  const downloadUrl = await uploadedFile.getSignedUrl(3600); // 1 hour expiration
  // Get the permanent S3 URL
  const s3Url = uploadedFile.getS3Key();
}
```

```typescript Serialization theme={null}
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
  });
  // Convert to dictionary for storage or API responses
  const fileDict = uploadedFile.toDict();
  const fileJson = uploadedFile.toJSON();
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.