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

```python theme={null}
class Attachment(BaseModel)
```

## Properties

<ParamField path="file_name" type="str">
  The name of the file in the S3 bucket
</ParamField>

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

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

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

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

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

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

## Methods

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

    **Returns:** `dict`

    Complete model data including all fields
  </Accordion>

  <Accordion title="to_dict">
    Converts the file metadata to a dictionary.

    **Returns:** `dict[str, str]`

    Dictionary with file\_name, key, bucket, region, endpoint, suggested\_file\_name, and file\_type
  </Accordion>

  <Accordion title="from_dict">
    Class method to create an Attachment instance from a dictionary.

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

    **Returns:** `str`

    Presigned URL for downloading the file
  </Accordion>

  <Accordion title="get_s3_key">
    Returns the full S3 URL for the file.

    **Returns:** `str`

    Complete S3 URL in format: [https://bucket.s3.region.amazonaws.com/filename](https://bucket.s3.region.amazonaws.com/filename)
  </Accordion>

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

    **Returns:** `str`

    The file\_name attribute (S3 object key)
  </Accordion>
</AccordionGroup>

## Examples

<CodeGroup>
  ```python Basic Usage theme={null}
  from intuned_browser import upload_file_to_s3, Attachment
  async def automation(page, params, **_kwargs):
      uploaded_file: Attachment = await upload_file_to_s3(
          file=my_file,
          configs=s3_config
      )

      # Access file properties
      print(uploaded_file.file_name)
      print(uploaded_file.suggested_file_name)
  ```

  ```python Working with Presigned URLs theme={null}
  from intuned_browser import upload_file_to_s3, Attachment
  async def automation(page, params, **_kwargs):
      uploaded_file: Attachment = await upload_file_to_s3(file=my_file)

      # Generate a presigned URL for temporary access
      download_url = await uploaded_file.get_signed_url(expiration=3600)  # 1 hour expiration

      # Get the permanent S3 URL
      s3_url = uploaded_file.get_s3_key()
  ```

  ```python Serialization theme={null}
  from intuned_browser import upload_file_to_s3, Attachment
  async def automation(page, params, **_kwargs):
      uploaded_file: Attachment = await upload_file_to_s3(file=my_file)

      # Convert to dictionary for storage or API responses
      file_dict = uploaded_file.to_dict()
      file_json = uploaded_file.__json__()
  ```
</CodeGroup>
