Services
File Service
The FileService handles file-related operations.
import asyncio
from t2g_sdk import T2GClient
async def main():
async with T2GClient() as client:
# Now you can access the FileService via client.file
# Example:
files = await client.file.find_files(ids=["some-file-id"])
pass
if __name__ == "__main__":
asyncio.run(main())The FileService handles file-related operations and is accessed via the file property of an active T2GClient instance.
upload_file
Uploads a file to the T2G API.
async def upload_file(file_path: str) -> Filefile_path: The path to the file to upload.
create_file
Creates a file record and returns a presigned URL for uploading.
async def create_file(name: str, source_hash: str) -> Dictname: The name of the file.source_hash: The SHA256 hash of the file's content.
find_files
Finds files by their IDs or source hashes.
async def find_files(ids: List[str] = None, source_hashes: List[str] = None) -> List[File]ids(optional): A list of file IDs to find.source_hashes(optional): A list of source hashes to find.