Skip to main content
Downloads a file from a web page and automatically uploads it to AWS S3 storage in a single operation. Combines downloadFile (for trigger methods) and uploadFileToS3 (for S3 configuration), providing a streamlined workflow for capturing and storing files.
export declare function saveFileToS3(input: {
  page: Page;
  trigger: Trigger;
  timeoutInMs?: number;
  configs?: S3Configs;
  fileNameOverride?: string;
  contentType?: string;
}): Promise<Attachment>;

Examples

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://sandbox.intuned.dev/pdfs/report.pdf",
    configs: {
      bucket: "document-storage",
      region: "us-east-1",
      accessKeyId: "accessKeyId",
      secretAccessKey: "SecretAccessKeyId",
    },
    fileNameOverride: "reports/monthly-report.pdf",
  });
  console.log(`File uploaded to: ${uploadedFile.getS3Key()}`);
}

Arguments

input
Object
required
Configuration object for the download and upload operation

Returns: Promise<Attachment>

Promise that resolves to an Attachment object with file metadata and S3 utilities