> ## Documentation Index
> Fetch the complete documentation index at: https://docs.usemoonshine.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Upload Files to Indexes

> Upload videos to an index

Moonshine accepts both local files and publicly-reachable URLs. Supported formats live here: [Filetypes](/reference/filetypes)

## Direct Upload

To upload a local video:

<CodeGroup>
  ```python python theme={null}
  file_id = await moonshine.upload(
      src="./your-video.mp4",
      index="your-index-name",
  )
  ```
</CodeGroup>

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:

<CodeGroup>
  ```python python theme={null}
  file_id = await moonshine.upload(
      src="https://example.com/video.mp4",
      index="your-index-name",
  )
  ```
</CodeGroup>

Every upload returns a globally unique `file_id`. Store it for future queries. File IDs are listed when getting the content of an index.

<Warning>
  Remote files must be publicly accessible.\
  Need secure cloud-to-cloud transfers? Reach out: [team@usemoonshine.com](mailto:team@usemoonshine.com)
</Warning>

## Optional progress callback

<CodeGroup>
  ```python python theme={null}
  def progress_callback(report: dict):
      print(report)
  ```
</CodeGroup>

This is an optional parameter that provides upload and indexing progress updates. The complete script to upload with callback looks like:

<CodeGroup>
  ```python python theme={null}
  file_id = await moonshine.upload(
      src="./your-video.mp4",
      index="your-index-name",
      progress_callback=progress_callback
  )
  ```
</CodeGroup>

## Complete Example

<CodeGroup>
  ```python python theme={null}
  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()
  ```
</CodeGroup>

***

<Accordion title=".upload() Params" icon="code-simple">
  <ParamField path="src" type="string" required>
    Local file path or remote URL to upload.
  </ParamField>

  <ParamField path="index" type="string" required>
    Name/ID of the destination index.
  </ParamField>

  <ParamField path="progress_callback" type="Callable[[dict], None">
    Optional. Receives granular progress updates (see keys above).
  </ParamField>
</Accordion>
