Store
The Store API allows you to manage files in the Airia platform. See the Store API reference and response types for more details.
Upload File
You can upload files to the Airia store using the upload_file method. This allows you to store documents, images, and other files that can be used by your pipelines.
from airia import AiriaClient
client = AiriaClient(api_key="your_api_key")
# Upload file
uploaded_file = client.store.upload_file(
store_connector_id="your_store_connector_id",
project_id="your_project_id",
file_path="document.pdf"
)
# Upload with folder organization
uploaded_file = client.store.upload_file(
store_connector_id="your_store_connector_id",
project_id="your_project_id",
file_path="document.pdf",
folder_id="your_folder_id"
)
Update File
You can update existing files in the Airia store using the update_file method. This allows you to replace the content of previously uploaded files.
from airia import AiriaClient
client = AiriaClient(api_key="your_api_key")
# Update existing file
updated_file_id = client.store.update_file(
store_connector_id="your_store_connector_id",
store_file_id="your_store_file_id",
project_id="your_project_id",
file_path="document.pdf"
)
Get File
You can retrieve file information from the Airia store using the get_file method. This returns metadata, download URLs, and preview information for files.
from airia import AiriaClient
client = AiriaClient(api_key="your_api_key")
# Get file information
file_info = client.store.get_file(
project_id="your_project_id",
file_id="your_file_id"
)
# Access file metadata
if file_info.file:
print(f"File name: {file_info.file.name}")
print(f"File size: {file_info.file.size} bytes")
print(f"MIME type: {file_info.file.mimeType}")
print(f"Status: {file_info.file.status}")
print(f"Processing duration: {file_info.file.ingestionDuration}ms")
# Access download URL
if file_info.downloadInfo:
print(f"Download URL: {file_info.downloadInfo.url}")
# Access preview information
if file_info.previewInfo:
print(f"Preview URL: {file_info.previewInfo.previewUrl}")
print(f"Description: {file_info.previewInfo.description}")
Get Files
You can retrieve information about all files in a store connector using the get_files method. This returns a list of files with their metadata, download URLs, and total count.
from airia import AiriaClient
client = AiriaClient(api_key="your_api_key")
# Get all files from a store connector
files_response = client.store.get_files(
project_id="your_project_id",
store_connector_id="your_store_connector_id"
)
# Access files list
if files_response.files:
print(f"Found {len(files_response.files)} files:")
for file in files_response.files:
print(f"- {file.name} ({file.size} bytes, Status: {file.status})")
if file.mimeType:
print(f" MIME Type: {file.mimeType}")
if file.path:
print(f" Path: {file.path}")
# Access download URLs
if files_response.downloadInfos:
print("\nDownload URLs:")
for download_info in files_response.downloadInfos:
print(f"- File ID: {download_info.fileId}")
print(f" URL: {download_info.url}")
# Access total count
print(f"\nTotal files in store connector: {files_response.totalCount}")
Delete File
You can delete files from the Airia store using the delete_file method. This permanently removes the file from the store.
from airia import AiriaClient
client = AiriaClient(api_key="your_api_key")
# Delete a file
client.store.delete_file(
project_id="your_project_id",
file_id="your_file_id"
)
# Handle deletion with error handling
try:
client.store.delete_file(
project_id="your_project_id",
file_id="your_file_id"
)
print("File deleted successfully")
except AiriaAPIError as e:
if e.status_code == 404:
print("File not found")