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
The name of the file in the S3 bucket
The key of the file in the S3 bucket
The S3 bucket name where the file is stored
The AWS region where the S3 bucket is located
Optional custom S3 endpoint URL. Defaults to None for standard AWS S3
A human-readable filename suggestion for downloads or display
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
Get Signed URL
Get S3 Key
Get File Path
Create from Dictionary
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 )