Skip to main content
export declare function saveFileToS3(input: {
  page: Page;
  trigger: Trigger;
  timeoutInMs?: number;
  configs?: S3Configs;
  fileNameOverride?: string;
  contentType?: string;
}): Promise<Attachment>;
Downloads a file from a web page and automatically uploads it to AWS S3 storage in a single operation. This convenience function combines the functionality of downloadFile and uploadFileToS3, providing a streamlined workflow for capturing files from web pages and storing them in S3. It supports the same flexible trigger methods as downloadFile with additional S3 upload configuration.
Trigger Behavior
  • URL
  • Locator
  • Callback
Creates a new page, navigates to the URL, waits for download, then automatically closes the page. Ideal for direct download links.
S3 Configuration Fallback MechanismThe function uses a smart fallback system to determine S3 settings:
1

S3Configs Parameter

If provided, uses the explicit S3Configs object with your custom settings.
2

Environment Variables

If no configs provided, automatically reads from environment variables:
  • AWS_ACCESS_KEY_ID - Your AWS access key
  • AWS_SECRET_ACCESS_KEY - Your AWS secret key
  • AWS_REGION - AWS region (e.g., “us-west-1”)
  • AWS_BUCKET - S3 bucket name
  • AWS_ENDPOINT_URL - Optional custom S3 endpoint
3

Intuned Defaults

If environment variables aren’t set, falls back to Intuned’s managed S3 storage.

Examples

import { saveFileToS3 } from "@intuned/browser";
export default async function handler(params, page, context){
// Download from URL and upload to S3 with custom configuration
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',
contentType: 'application/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