docs: clarify file upload with API snippet (#9384)

* clarify-file-upload-with-api-snippet

* style

* Apply suggestions from code review

Co-authored-by: April I. Murphy <36110273+aimurphy@users.noreply.github.com>

---------

Co-authored-by: April I. Murphy <36110273+aimurphy@users.noreply.github.com>
This commit is contained in:
Mendon Kissling 2025-08-14 14:56:12 -04:00 • committed by GitHub
commit 8fff7cc4a4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -54,7 +54,34 @@ For more information about the **File** component and other data loading compone
### Load files at runtime ### Load files at runtime
You can use preloaded files in your flows, and you can load files at runtime, if your flow accepts file input. You can use preloaded files in your flows, and you can load files at runtime, if your flow accepts file input.
For an example, see [Create a chatbot that can ingest files](/chat-with-files). To enable file input in your flow, do the following:
1. Add a [**File** component](/components-data#file) to your flow.
2. Click **Share**, select **API access**, and then click **Input Schema** to add [`tweaks`](/concepts-publish#input-schema) to the request payload in the flow's automatically generated code snippets.
3. Expand the **File** section, find the **Files** row, and then enable **Expose Input** to allow the parameter to be set at runtime through the Langflow API.
4. Close the **Input Schema** pane to return to the **API access** pane.
The payload in each code snippet now includes `tweaks`, your **File** component's ID, and the `path` key that you enabled in **Input Schema**:
```json
"tweaks": {
"File-qYD5w": {
"path": []
}
}
```
5. When you run this flow programmatically, your script must upload a file to Langflow file management, and then pass the returned `file_path` to the `path` tweak in the `/run` request:
```json
"tweaks": {
"FILE_COMPONENT_ID": {
"path": [ "file_path" ]
}
}
```
For a complete example see [Create a chatbot that can ingest files](/chat-with-files) and [Files endpoints](/api-files).
If you want to upload multiple files, you can pass multiple `file_path` values in the `path` array, such as `[ "path1", "path2" ]`.
## Upload images ## Upload images