aixplain.v2.file
Simple Resource class for file handling and S3 uploads.
ResourceGetParams Objects
@dataclass_json
@dataclass
class ResourceGetParams()
Parameters for getting resources.
Resource Objects
@dataclass_json
@dataclass(repr=False)
class Resource(BaseResource)
Simple resource class for file handling and S3 uploads.
This class provides the basic functionality needed for the requirements:
- File path handling
- S3 upload via save()
- URL access after upload
__post_init__
def __post_init__()
Initialize the resource.
build_save_payload
def build_save_payload(**kwargs) -> dict
Build the payload for saving the resource.
save
def save(is_temp: Optional[bool] = None, **kwargs) -> "Resource"
Save the resource, uploading file to S3 if needed.
Arguments:
is_temp- Whether this is a temporary upload. If None, uses the resource's is_temp setting.**kwargs- Additional parameters for saving.
url
@property
def url() -> Optional[str]
Get the presigned/public URL of the uploaded file.
create_from_file
@classmethod
def create_from_file(cls,
file_path: str,
is_temp: bool = True,
**kwargs) -> "Resource"
Create a resource from a file path.
Arguments:
file_path- Path to the file to upload.is_temp- Whether this is a temporary upload (default: True).**kwargs- Additional parameters for initialization.
__init__
def __init__(file_path: Optional[str] = None, is_temp: bool = True, **kwargs)
Initialize the resource with file path.
Arguments:
file_path- Path to the file to upload.is_temp- Whether this is a temporary upload (default: True).**kwargs- Additional parameters for initialization.