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

# saveFileToS3

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

Combines [downloadFile](./downloadFile) (for trigger methods) and [uploadFileToS3](./uploadFileToS3)
(for S3 configuration), providing a streamlined workflow for capturing and storing files.

```typescript theme={null}
export declare function saveFileToS3(input: {
  page: Page;
  trigger: Trigger;
  timeoutInMs?: number;
  configs?: S3Configs;
  fileNameOverride?: string;
  contentType?: string;
}): Promise<Attachment>;
```

## Examples

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

  interface Params {}

  export default async function handler(
    params: Params,
    page: Page,
    context: BrowserContext
  ) {
    const uploadedFile = await saveFileToS3({
      page,
      trigger:
        "https://intuned-docs-public-images.s3.amazonaws.com/27UP600_27UP650_ENG_US.pdf",
      configs: {
        bucket: "document-storage",
        region: "us-east-1",
        accessKeyId: "accessKeyId",
        secretAccessKey: "SecretAccessKeyId",
      },
      fileNameOverride: "reports/monthly-report.pdf",
    });
    return { file: uploadedFile };
  }
  ```

  ```typescript Locator Trigger theme={null}
  import { saveFileToS3 } from "@intuned/browser";
  import { BrowserContext, Page } from "playwright";

  interface Params {}

  export default async function handler(
    params: Params,
    page: Page,
    context: BrowserContext
  ) {
    await page.goto("https://sandbox.intuned.dev/pdfs");
    const uploadedFile = await saveFileToS3({
      page,
      trigger: page.locator("xpath=//tbody/tr[1]//*[name()='svg']"),
      timeoutInMs: 10000,
    });
    const downloadUrl = await uploadedFile.getSignedUrl(7200); // 2 hours
    console.log(`Temporary access: ${downloadUrl}`);
  }
  ```
</CodeGroup>

## Arguments

<ResponseField name="input" type="Object" required>
  Configuration object for the download and upload operation

  <Expandable title="properties" defaultOpen>
    <ResponseField name="input.page" type="Page" required>
      The Playwright Page object to use for downloading
    </ResponseField>

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

    <ResponseField name="input.timeoutInMs" type="number">
      Maximum time in milliseconds to wait for download to start. Defaults to 5000.
    </ResponseField>

    <ResponseField name="input.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="input.fileNameOverride" type="string">
      Optional custom filename for the uploaded file. If not provided, uses the
      original filename or generates a unique name.
    </ResponseField>

    <ResponseField name="input.contentType" type="string">
      Optional MIME type for the uploaded file (e.g., “application/pdf”,
      “image/png”).
    </ResponseField>
  </Expandable>
</ResponseField>

## Returns: `Promise<Attachment>`

Promise that resolves to an [Attachment](../type-references/Attachment) object with file metadata and S3 utilities
