Skip to main content
async def save_file_to_s3(
    page: Page,
    trigger: Trigger,
    *,
    timeout_s: int = 5,
    configs: S3Configs | None = None,
    file_name_override: str | None = None,
    content_type: str | None = None,
) -> 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 download_file and upload_file_to_s3, providing a streamlined workflow for capturing files from web pages and storing them in S3. It supports the same flexible trigger methods as download_file 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

from intuned_browser import save_file_to_s3, S3Configs
async def automation(page, params, **_kwargs):
    await page.goto("https://sandbox.intuned.dev/pdfs")
    configs = S3Configs(
        bucket_name="my-bucket",
        region="us-west-1",
        access_key="YOUR_ACCESS_KEY",
        secret_key="YOUR_SECRET_KEY"
    )
    uploaded_file = await save_file_to_s3(
        page=page,
        trigger=page.locator("xpath=//tbody/tr[1]//*[name()='svg']"),
        timeout_s=10,
        configs=configs
    )
    print(f"File uploaded to: {uploaded_file.key}")

Arguments

page
Page
required
The Playwright Page object to use for downloading
trigger
Trigger
required
The Trigger method to initiate the download. See trigger behavior section above for details.
timeout_s
int
default:"5"
Maximum time in seconds to wait for download completion. Defaults to 5.
configs
S3Configs
default:"None"
Optional S3Configs to customize the S3 upload. See S3 configuration fallback mechanism above for details. Defaults to None.
file_name_override
str
Optional custom filename for the uploaded file. If None, uses the original filename or generates a unique name.
content_type
str
Optional MIME type for the uploaded file (e.g., “application/pdf”, “image/png”). If None, uses the original content type.

Returns: Attachment

An Attachment object with file metadata and S3 utilities