Skip to main content
Downloads a file from a web page and automatically uploads it to AWS S3 storage in a single operation. Combines download_file (for trigger methods) and upload_file_to_s3 (for S3 configuration), providing a streamlined workflow for capturing and storing files.
async def save_file_to_s3(
    page: Page,
    trigger: Trigger,
    *,
    timeout_s: int,
    configs: S3Configs | None,
    file_name_override: str | None,
    content_type: str | None,
) -> Attachment

Examples

from typing import TypedDict
from playwright.async_api import Page
from intuned_browser import save_file_to_s3, S3Configs
class Params(TypedDict):
    pass
async def automation(page: Page, params: Params, **_kwargs):
    uploaded_file = await save_file_to_s3(
        page=page,
        trigger="https://sandbox.intuned.dev/pdfs/report.pdf",
        configs=S3Configs(
            bucket_name='document-storage',
            region='us-east-1',
            access_key='accessKeyId',
            secret_key='SecretAccessKeyId'
        ),
        file_name_override='reports/monthly-report.pdf'
    )
    print(f"File uploaded to: {uploaded_file.get_s3_key()}")

Arguments

page
Page
required
The Playwright Page object to use for downloading
trigger
Trigger
required
The Trigger method to initiate the download.
timeout_s
int
Maximum time in seconds to wait for download to start. Defaults to 5.
configs
S3Configs
Optional 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.
file_name_override
str
Optional custom filename for the uploaded file. If not provided, 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