Skip to main content
export declare function uploadFileToS3(input: {
  file: FileType;
  configs?: S3Configs;
  fileNameOverride?: string;
  contentType?: string;
}): Promise<Attachment>;
Uploads files to AWS S3 storage with flexible configuration options. This function accepts various file types including Playwright Download objects, binary data, and file streams, making it versatile for different upload scenarios. It automatically handles file metadata and provides comprehensive S3 configuration options.
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 { downloadFile, uploadFileToS3 } from "@intuned/browser";
export default async function handler(params, page, context){
// Download and upload a file with custom S3 configuration
await page.goto("https://sandbox.intuned.dev/pdfs")
const download = await downloadFile({
  page,
  trigger: page.locator("xpath=//tbody/tr[1]//*[name()='svg']")
});

const uploadedFile = await uploadFileToS3({
  file: download,
  configs: {
      bucket: 'my-documents',
      region: 'us-west-2',
      accessKeyId: 'accessKeyId',
      secretAccessKey: 'SecretAccessKeyId'
    },
    fileNameOverride: 'reports/monthly-report.pdf'
  }
});

console.log(`File uploaded: ${uploadedFile.suggestedFileName}`);
console.log(`S3 URL: ${uploadedFile.getS3Key()}`);
}

Arguments

input
Object
required
Configuration object for the upload operation

Returns: Promise<Attachment>

Promise that resolves to an Attachment object with file metadata and utility methods