Bulk Uploads
ArchiHUB makes bulk document uploads easy with a script that respects your system’s folder hierarchy. This guide will show you how to set up and use this tool to efficiently migrate large volumes of documents.
Prerequisites
Section titled “Prerequisites”- Python 3.8 or higher
- Git installed on your system
- An ArchiHUB admin key (learn how to generate one here)
Step-by-Step Instructions
Section titled “Step-by-Step Instructions”-
Clone the repository
Download the repository containing the upload scripts:
Ventana de terminal git clone https://github.com/ArchiHUB-App/getting-started.git -
Configure API credentials
Navigate to the scripts folder and create a configuration file:
Ventana de terminal cd getting-started/scriptstouch .env -
Set up environment variables
Open the
.envfile and add the following lines, replacing with your credentials:ARCHIHUB_API_KEY="your-admin-key"ARCHIHUB_API_URL="http://localhost:11000/adminApi" -
Set up Python environment
Create and activate a virtual environment to install dependencies:
Ventana de terminal python3 -m venv folder_loadsource folder_load/bin/activatepip install -r requirements.txt -
Run the upload script
Navigate to the scripts folder and run the upload command. Make sure to adjust the path according to your configuration:
Ventana de terminal cd getting-started/scriptspython3 folder_load.py --folder /path/to/your/folder --publish true
Script Parameters
Section titled “Script Parameters”The bulk upload script accepts the following parameters:
Required Parameters
Section titled “Required Parameters”--folder- Description: Absolute path to the root folder containing the documents to upload.
- Example:
/full/path/to/your/folder - Note: The folder structure will be preserved in ArchiHUB.
Optional Parameters
Section titled “Optional Parameters”--publish- Description: Automatically publishes the uploaded documents.
- Values:
trueorfalse - Default:
false(documents are saved as drafts) - Recommendation: Use
truefor production,falsefor testing.
Practical Example
Section titled “Practical Example”Suppose you have the following folder structure:
Documents/├── Project A/│ ├── Contract.pdf│ └── Budget.xlsx└── Project B/ ├── Invoice.pdf └── Receipt.pdfTo upload these documents while maintaining the structure, you would use:
python3 folder_load.py --folder /path/to/Documents --publish trueIf you want to upload the example folder included in the repository, you can use the following command (adjust the path according to your system):
cd getting-started/scriptspython3 folder_load.py --folder ~/dev/archihub/getting-started/scripts/Assets --publish trueThis command will upload the contents of the Assets folder, which includes sample files to test the functionality.
Troubleshooting
Section titled “Troubleshooting”- Authentication Error: Verify that the API key in the
.envfile is correct. - Path Not Found: Make sure the path specified in
--folderexists. - Permission Denied: Check that you have write permissions for the target folder.