Moonshine accepts both local files and publicly-reachable URLs. Supported formats live here: Filetypes
Direct Upload
To upload a local video:
file_id = await moonshine.upload(
src="./your-video.mp4",
index="your-index-name",
)
Every upload returns a globally unique file_id
. Store it for future queries. File IDs are listed when getting the content of an index.
Remote Upload
To upload a remote video:
file_id = await moonshine.upload(
src="https://example.com/video.mp4",
index="your-index-name",
)
Every upload returns a globally unique file_id
. Store it for future queries. File IDs are listed when getting the content of an index.
Remote files must be publicly accessible.
Need secure cloud-to-cloud transfers? Reach out: team@usemoonshine.com
Optional progress callback
def progress_callback(report: dict):
print(report)
This is an optional parameter that provides upload and indexing progress updates. The complete script to upload with callback looks like:
file_id = await moonshine.upload(
src="./your-video.mp4",
index="your-index-name",
progress_callback=progress_callback
)
Complete Example
import moonshine
import asyncio
moonshine.config('YOUR TOKEN HERE')
async def upload_file(src, index):
def progress_callback(report: dict):
print(report)
file_id = await moonshine.upload(
src=src,
index=index,
progress_callback=progress_callback
)
return file_id
async def main():
file_id = await upload_file("your-video.mp4", "your-index-name")
print(f'File ID: {file_id}')
await main()
Local file path or remote URL to upload.
Name/ID of the destination index.
Optional. Receives granular progress updates (see keys above).