> ## 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

<ParamField path="fileName" type="string">
  The name/key of the file in the S3 bucket
</ParamField>

<ParamField path="key" type="string">
  The S3 object key/path
</ParamField>

<ParamField path="bucket" type="string">
  The S3 bucket name where the file is stored
</ParamField>

<ParamField path="region" type="string">
  The AWS region where the S3 bucket is located
</ParamField>

<ParamField path="endpoint" type="string">
  Optional custom S3 endpoint URL. Defaults to undefined for standard AWS S3
</ParamField>

<ParamField path="suggestedFileName" type="string">
  A human-readable filename suggestion for downloads or display
</ParamField>

<ParamField path="fileType" type="AttachmentType">
  The file type of the file
</ParamField>

## Methods

<AccordionGroup>
  <Accordion title="toJSON">
    Returns a JSON-serializable record representation of the file.

    **Returns:** `Record<string, string>`

    Complete model data including all fields
  </Accordion>

  <Accordion title="toDict">
    Converts the file metadata to a record.

    **Returns:** `Record<string, string>`

    Record with fileName, key, bucket, region, endpoint, suggestedFileName, and fileType
  </Accordion>

  <Accordion title="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>

  <Accordion title="getFilePath">
    Returns the file path/key within the S3 bucket.

    **Returns:** `string`

    The fileName property (S3 object key)
  </Accordion>

  <Accordion title="getSignedUrl">
    Generates a presigned URL for secure, temporary access to the file.

    <ParamField path="expiration" type="any">
      URL expiration time in seconds. Defaults to 432000 (5 days)
    </ParamField>

    **Returns:** `Promise<string>`

    Presigned URL for downloading the file
  </Accordion>
</AccordionGroup>

## Examples

<CodeGroup>
  ```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();
  }
  ```
</CodeGroup>
