Skip to main content
Version: 2.0

aixplain.v2.file

Simple Resource class for file handling and S3 uploads.

ResourceGetParams Objects

@dataclass_json

@dataclass
class ResourceGetParams()

[view_source]

Parameters for getting resources.

Resource Objects

@dataclass_json

@dataclass(repr=False)
class Resource(BaseResource)

[view_source]

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__()

[view_source]

Initialize the resource.

build_save_payload

def build_save_payload(**kwargs) -> dict

[view_source]

Build the payload for saving the resource.

save

def save(is_temp: Optional[bool] = None, **kwargs) -> "Resource"

[view_source]

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]

[view_source]

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"

[view_source]

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)

[view_source]

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.