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
URL Trigger
Locator Trigger
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
The Playwright Page object to use for downloading
The Trigger method to initiate the download.
Maximum time in seconds to wait for download to start. Defaults to 5.
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.
Optional custom filename for the uploaded file. If not provided, uses the original filename or generates a unique name.
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