Skip to main content
async def upload_file_to_s3(
    file: FileType,
    *,
    configs: S3Configs | None = None,
    file_name_override: str | None = None,
    content_type: str | None = None,
) -> Attachment
Uploads files to AWS S3 storage with flexible configuration options. This function accepts various file types including Playwright Download objects, binary data, 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

from intuned_browser import download_file, upload_file_to_s3, S3Configs
async def automation(page, params, **_kwargs):
    # Download a file first
    download = await download_file(page, "https://intuned-docs-public-images.s3.amazonaws.com/32UP83A_ENG_US.pdf")
    # Configure S3 configuration
    s3_config = S3Configs(
        bucket_name='my-bucket',
        region='us-west-1',
        access_key='YOUR_ACCESS_KEY',
        secret_key='YOUR_SECRET_KEY'
    )
    uploaded_file = await upload_file_to_s3(download, configs=s3_config, file_name_override="myfile.pdf", content_type="application/pdf")
    print(uploaded_file.get_s3_key())

Arguments

file
FileType
required
  • Playwright Download object - bytes (binary data)
configs
S3Configs
default:"None"
Optional S3Configs for customizing the S3 upload. See 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 utility methods