Skip to main content
class Attachment(BaseModel)
Represents an uploaded file stored in AWS S3 with metadata and utility methods. This class provides a structured way to handle file information for files stored in S3, including methods for generating signed URLs, serialization, and accessing file metadata.

Parameters

file_name
str
The name of the file in the S3 bucket
key
str
The key of the file in the S3 bucket
bucket
str
The S3 bucket name where the file is stored
region
str
The AWS region where the S3 bucket is located
endpoint
str
Optional custom S3 endpoint URL. Defaults to None for standard AWS S3
suggested_file_name
str
A human-readable filename suggestion for downloads or display
file_type
AttachmentType
The type of the file, either ‘document’ or ‘image’

Methods

__json__

Returns a JSON-serializable dictionary representation of the file. Returns: dict: Complete model data including all fields Examples:
from intuned_browser import Attachment
async def automation(page, params, **_kwargs):
file = Attachment(file_name='docs/report.pdf', key='docs/report.pdf', bucket='uploads', region='us-east-1', endpoint=None, suggested_file_name='Report.pdf', file_type='document')
file.__json__()
{
'file_name': 'docs/report.pdf',
'key': 'docs/report.pdf',
'bucket': 'uploads',
'region': 'us-east-1',
'endpoint': None,
'suggested_file_name': 'Report.pdf',
'file_type': 'document'
}

to_dict

Converts the file metadata to a dictionary, excluding the endpoint field. Returns: dict[str, str]: Dictionary with file_name, key, bucket, region, endpoint, suggested_file_name, and file_type Examples:
from intuned_browser import Attachment
async def automation(page, params, **_kwargs):
file = Attachment(file_name='docs/report.pdf', key='docs/report.pdf', bucket='uploads', region='us-east-1', endpoint=None, suggested_file_name='Report.pdf', file_type='document')
file.to_dict()
{
'file_name': 'docs/report.pdf',
'key': 'docs/report.pdf',
'bucket': 'uploads',
'region': 'us-east-1',
'endpoint': None,
'suggested_file_name': 'Report.pdf',
'file_type': 'document'
}

from_dict

Class method to create an Attachment instance from a dictionary. Parameters:
  • data dict[str, str]: Dictionary containing file metadata with keys:
    • file_name: The S3 object key
    • key: The key of the file in the S3 bucket
    • bucket: S3 bucket name
    • region: AWS region
    • file_type: The type of the file, AttachmentType
    • suggested_file_name: Display name for the file
    • endpoint (optional): Custom S3 endpoint
Returns: Attachment: New instance created from the dictionary data Examples:
from intuned_browser import Attachment
async def automation(page, params, **_kwargs):
data = {'file_name': 'docs/report.pdf', 'key': 'docs/report.pdf', 'bucket': 'uploads',
'region': 'us-east-1', 'endpoint': None, 'suggested_file_name': 'Report.pdf', 'file_type': 'document'}
file = Attachment.from_dict(data)

Examples

from intuned_browser import Attachment
                async def automation(page, params, **_kwargs):
                    file = Attachment(file_name='docs/report.pdf', key='docs/report.pdf', bucket='uploads', region='us-east-1', endpoint=None, suggested_file_name='Report.pdf', file_type='document')
                    url = await file.get_signed_url(expiration=3600)