Download Files
Download files from a Haystack Enterprise Platform workspace to your local machine. You can use the CLI or Python SDK to do it.
About This Task
By default, download fetches every file in the workspace and writes it to the folder you're in. Use the flags below to choose where the files go and which files to download.
When using the Haystack Enterprise SDK on Windows, if haystack-enterprise isn't on your PATH, replace it with python -m haystack_enterprise_sdk.cli, for example:
haystack-enterprise validate pipeline.py
becomes
python -m haystack_enterprise_sdk.cli validate pipeline.py
Metadata
By default, the SDK also downloads each file's metadata into a matching .meta.json file next to the file:
report.pdf
report.pdf.meta.json
To download the files without their metadata, add --no-include-meta.
Choosing Which Files to Download
To download a subset of the workspace, filter by file name or by metadata:
--namedownloads only files whose name matches.--odata-filterdownloads only files whose metadata matches an OData filter, for example--odata-filter "category eq 'news'".
Prerequisites
Set up the SDK to authenticate and specify the workspace you want to download from.
Download Files
Run the following command, replacing my-workspace with the workspace you want to download from:
haystack-enterprise download --workspace-name my-workspace
This writes the files to the current folder. To download them somewhere else, add --file-dir with the target folder:
haystack-enterprise download --workspace-name my-workspace --file-dir ./downloaded-files
Download with Python
This is an example script you can use to download a workspace's files to a local folder:
from haystack_enterprise_sdk.workflows.sync_client.files import download
download(
workspace_name="my-workspace",
file_dir="./downloaded-files", # defaults to the current folder
include_meta=True, # also write each file's .meta.json
batch_size=50, # files fetched per request
)
Examples
- Download every file to a specific folder:
haystack-enterprise download --workspace-name my-workspace --file-dir ./downloaded-files
- Download only files with a specific name:
haystack-enterprise download --workspace-name my-workspace --name "report.pdf"
- Download only files whose metadata matches a filter:
haystack-enterprise download --workspace-name my-workspace --odata-filter "category eq 'news'"
- Download the files without their metadata:
haystack-enterprise download --workspace-name my-workspace --no-include-meta
- Download with INFO and DEBUG logs turned on:
haystack-enterprise --verbose download --workspace-name my-workspace
Related Information
Was this page helpful?