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

# save_file_to_s3

Downloads a file from a web page and automatically uploads it to AWS S3 storage in a single operation.

Combines [download\_file](./download_file) (for trigger methods) and [upload\_file\_to\_s3](./upload_file_to_s3)
(for S3 configuration), providing a streamlined workflow for capturing and storing files.

```python theme={null}
async def save_file_to_s3(
    page: Page,
    trigger: Trigger,
    *,
    timeout_s: int,
    configs: S3Configs | None,
    file_name_override: str | None,
    content_type: str | None,
) -> Attachment
```

## Examples

<CodeGroup>
  ```python URL Trigger theme={null}
  from typing import TypedDict
  from playwright.async_api import Page
  from intuned_browser import save_file_to_s3, S3Configs
  class Params(TypedDict):
      pass
  async def automation(page: Page, params: Params, **_kwargs):
      uploaded_file = await save_file_to_s3(
          page=page,
          trigger="https://intuned-docs-public-images.s3.amazonaws.com/27UP600_27UP650_ENG_US.pdf",
          configs=S3Configs(
              bucket_name='document-storage',
              region='us-east-1',
              access_key='accessKeyId',
              secret_key='SecretAccessKeyId'
          ),
          file_name_override='reports/monthly-report.pdf'
      )
      return {"file": uploaded_file}
  ```

  ```python Locator Trigger theme={null}
  from typing import TypedDict
  from playwright.async_api import Page
  from intuned_browser import save_file_to_s3
  class Params(TypedDict):
      pass
  async def automation(page: Page, params: Params, **_kwargs):
      await page.goto("https://sandbox.intuned.dev/pdfs")
      uploaded_file = await save_file_to_s3(
          page=page,
          trigger=page.locator("xpath=//tbody/tr[1]//*[name()='svg']"),
          timeout_s=10
      )
      download_url = await uploaded_file.get_signed_url(7200)  # 2 hours
      print(f"Temporary access: {download_url}")
  ```
</CodeGroup>

## Arguments

<ResponseField name="page" type="Page" required>
  The Playwright Page object to use for downloading
</ResponseField>

<ResponseField name="trigger" type="Trigger" required>
  The [Trigger](../type-references/Trigger) method to initiate the download.
</ResponseField>

<ResponseField name="timeout_s" type="int">
  Maximum time in seconds to wait for download to start. Defaults to 5.
</ResponseField>

<ResponseField name="configs" type="S3Configs">
  Optional [S3Configs](../type-references/S3Configs) to customize the S3 upload.
  If not provided, uses environment variables (`AWS_ACCESS_KEY_ID`,
  `AWS_SECRET_ACCESS_KEY`, `AWS_REGION`, `AWS_ENDPOINT_URL`, `AWS_BUCKET`). If
  environment variables aren't set, uses default Intuned S3 settings.
</ResponseField>

<ResponseField name="file_name_override" type="str">
  Optional custom filename for the uploaded file. If not provided, uses the
  original filename or generates a unique name.
</ResponseField>

<ResponseField name="content_type" type="str">
  Optional MIME type for the uploaded file (e.g., "application/pdf",
  "image/png"). If None, uses the original content type.
</ResponseField>

## Returns: `Attachment`

An [Attachment](../type-references/Attachment) object with file metadata and S3 utilities
