File Upload API#

File Uploads#

Example Use Inside of an Adapter Action

@action()
async def file_upload(self, actx: ActionExecutionContext) -> None:
    await self.artificial_api.file_upload_api_v1.upload_file(
        actx=actx,
        file_contents=b'File contents',
        uploaded_filename='FileName.txt',
        description='Example File',
        notes='Example File Upload',
        metadata={'metadata_key': 'metadata_value'},
        tags=['tag_name'],
    )
class FileUploadApi(connections: Connections)#

Provides the ability to upload files to the Artificial platform.

async upload_file(
*,
actx: fileupload.UploadContext,
file_path: str,
uploaded_filename: str,
description: str = '',
notes: str = '',
metadata: t.Dict[str, str] = {},
tags: t.List[str] = [],
uploader: t.Optional[fileupload.FileUploader] = None,
) str#
async upload_file(
*,
action_id: str,
lab_id: str,
job_id: str,
file_path: str,
uploaded_filename: str,
description: str = '',
notes: str = '',
metadata: t.Dict[str, str] = {},
tags: t.List[str] = [],
uploader: t.Optional[fileupload.FileUploader] = None,
) str
async upload_file(
*,
actx: fileupload.UploadContext,
file_contents: bytes,
uploaded_filename: str,
description: str = '',
notes: str = '',
metadata: t.Dict[str, str] = {},
tags: t.List[str] = [],
uploader: t.Optional[fileupload.FileUploader] = None,
) str
async upload_file(
*,
action_id: str,
lab_id: str,
job_id: str,
file_contents: bytes,
uploaded_filename: str,
description: str = '',
notes: str = '',
metadata: t.Dict[str, str] = {},
tags: t.List[str] = [],
uploader: t.Optional[fileupload.FileUploader] = None,
) str

Uploads a file to the the job record in the Artificial platform.

Parameters:
  • file_contents – The contents of the file to upload

  • file_path – The path to the file to upload

  • uploaded_filename – The filename to use for the uploaded file

  • description – The description of the uploaded file, defaults to ‘’

  • notes – Notes for the uploaded file, defaults to ‘’

  • metadata – Metadata for the uploadedfile, defaults to {}

  • tags – Tags for the uploaded file, defaults to []

Raises:

ValueError – If neither file_path nor file_contents is provided