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

# Upload files to S3

## Recipe

This recipe shows how to upload files to S3 with [`uploadFileToS3`](/automation-sdks/intuned-sdk/typescript/helpers/functions/uploadFileToS3) (TypeScript) or [`upload_file_to_s3`](/automation-sdks/intuned-sdk/python/helpers/functions/upload_file_to_s3) (Python).

## Using uploadFileToS3 / upload\_file\_to\_s3

<CodeGroup dropdown>
  ```typescript TypeScript theme={null}
  import { BrowserContext, Page } from "playwright";
  import { uploadFileToS3 } from "@intuned/browser"

  export default async function handler(
    params: any,
    page: Page,
    context: BrowserContext
  ) {
    await page.goto("https://sandbox.intuned.dev/pdfs")

    // Wait for download event and click the trigger
    const [download] = await Promise.all([
      page.waitForEvent("download"),
      page.locator("xpath=//tbody/tr[1]//*[name()='svg']").click(),
    ])

    // Upload the Playwright Download object to S3
    const uploadedFile = await uploadFileToS3({
      file: download,
      fileNameOverride: "myfile.pdf",
    })

    // Get signed URL for access
    const signedUrl = await uploadedFile.getSignedUrl()
    console.log(
      `Download uploaded file by clicking on: \x1b[1;4;36m\x1b]8;;${signedUrl}\x1b\\Click here\x1b]8;;\x1b\\\x1b[0m \n`
    )
    return uploadedFile
  }
  ```

  ```python Python theme={null}
  from intuned_browser import upload_file_to_s3
  from playwright.async_api import Page

  async def automation(page: Page, params, **_kwargs):
      await page.goto("https://sandbox.intuned.dev/pdfs")

      # Wait for download event and click the trigger
      async with page.expect_download() as download_info:
          await page.locator("xpath=//tbody/tr[1]//*[name()='svg']").click()
      download = await download_info.value

      # Upload the Playwright Download object to S3
      uploaded_file = await upload_file_to_s3(
          download,
          file_name_override="myfile.pdf",
          content_type="application/pdf",
      )

      # Get signed URL for access
      signed_url = await uploaded_file.get_signed_url()
      print(
          f"Download uploaded file by clicking on: \033[1;4;36m\033]8;;{signed_url}\033\\Click here\033]8;;\033\\\033[0m \n"
      )
      return uploaded_file
  ```
</CodeGroup>

## Using saveFileToS3 / save\_file\_to\_s3

[`saveFileToS3`](/automation-sdks/intuned-sdk/typescript/helpers/functions/saveFileToS3) (TypeScript) or [`save_file_to_s3`](/automation-sdks/intuned-sdk/python/helpers/functions/save_file_to_s3) (Python) combines downloading and uploading in one step.

<CodeGroup dropdown>
  ```typescript TypeScript theme={null}
  import { BrowserContext, Page } from "playwright";
  import { saveFileToS3 } from "@intuned/browser"

  interface Params {
    // Add your params here
  }

  export default async function handler(
    params: Params,
    page: Page,
    context: BrowserContext
  ) {
    await page.goto("https://sandbox.intuned.dev/pdfs")

    // Locate the download button
    const downloadLocator = page.locator("xpath=//tbody/tr[1]//*[name()='svg']")

    // Download and upload to S3 in one step
    const uploadedFile = await saveFileToS3({
      page,
      trigger: downloadLocator,
      timeoutInMs: 15000,
    })

    // Get signed URL for access
    const signedUrl = await uploadedFile.getSignedUrl()
    console.log(
      `Download uploaded file by clicking on: \x1b[1;4;36m\x1b]8;;${signedUrl}\x1b\\Click here\x1b]8;;\x1b\\\x1b[0m \n`
    )
    return uploadedFile
  }
  ```

  ```python Python theme={null}
  from intuned_browser import download_file
  from intuned_browser.helpers import save_file_to_s3
  from playwright.async_api import Page

  async def automation(page: Page, params, **_kwargs):
      await page.goto("https://sandbox.intuned.dev/pdfs")

      # Locate the download button
      download_locator = page.locator("xpath=//tbody/tr[1]//*[name()='svg']")

      # Download and upload to S3 in one step
      uploaded_file = await save_file_to_s3(
          page=page,
          trigger=download_locator,
          timeout_s=15,
      )

      # Get signed URL for access
      signed_url = await uploaded_file.get_signed_url()
      print(
          f"Download uploaded file by clicking on: \033[1;4;36m\033]8;;{signed_url}\033\\Click here\033]8;;\033\\\033[0m \n"
      )
      return uploaded_file
  ```
</CodeGroup>

## Related SDK methods

<CardGroup cols={2}>
  <Card title="uploadFileToS3 (TypeScript)" icon="js" href="/automation-sdks/intuned-sdk/typescript/helpers/functions/uploadFileToS3">
    TypeScript SDK helper for uploading files to S3
  </Card>

  <Card title="upload_file_to_s3 (Python)" icon="python" href="/automation-sdks/intuned-sdk/python/helpers/functions/upload_file_to_s3">
    Python SDK helper for uploading files to S3
  </Card>

  <Card title="saveFileToS3 (TypeScript)" icon="js" href="/automation-sdks/intuned-sdk/typescript/helpers/functions/saveFileToS3">
    TypeScript SDK helper for downloading and uploading to S3 in one step
  </Card>

  <Card title="save_file_to_s3 (Python)" icon="python" href="/automation-sdks/intuned-sdk/python/helpers/functions/save_file_to_s3">
    Python SDK helper for downloading and uploading to S3 in one step
  </Card>

  <Card title="Cookbook (Python)" icon="github" href="https://github.com/Intuned/cookbook/tree/main/python-examples/quick-recipes">
    Python quick recipes in the Intuned Cookbook
  </Card>

  <Card title="Cookbook (TypeScript)" icon="github" href="https://github.com/Intuned/cookbook/tree/main/typescript-examples/quick-recipes">
    TypeScript quick recipes in the Intuned Cookbook
  </Card>
</CardGroup>
