Bash Script Guide
Warning
Currently, only the upload endpoint is documented as a batch script.
Script Setup
Save the following script as your-script-name.bat in your desired directory:
@echo off
setlocal enabledelayedexpansion
set API_URL=https://file-exchange.populaer.ch/upload
set X_AUTH_NAME=__AUTH_NAME__
set X_AUTH_PASSWORD=__AUTH_PASSWORD__
rem Define the paths to the files - Ensure correct syntax (copy the path from Explorer)
rem You can add or remove file paths as needed, ensuring sequential numbering [0],[1], etc...
set "FILE_PATHS[0]=C:\\path\\to\\your\\file0.txt"
set "FILE_PATHS[1]=C:\\path\\to\\your\\file1.txt"
set "FILE_PATHS[2]=C:\\path\\to\\your\\file2.txt"
set "FILE_PATHS[3]=C:\\path\\to\\your\\file3.txt"
set "TEMP_DIR=%TEMP%"
set "TEMP_FILE=%TEMP_DIR%\curl_output.txt"
rem Loop through the array of file paths
for /l %%i in (0,1,100) do (
set "FILE_PATH=!FILE_PATHS[%%i]!"
if defined FILE_PATH (
curl -X POST %API_URL% -H "x-auth-name: %X_AUTH_NAME%" -H "x-auth-password: %X_AUTH_PASSWORD%" -F "file=@!FILE_PATH!" -o !TEMP_FILE!
REM Display response from the server
type !TEMP_FILE!
del !TEMP_FILE!
)
)
endlocal
Customize Script Variables
- API_URL: Set the URL of the File Exchange API endpoint where files will be uploaded.
- X_AUTH_NAME: Set your customer name for authentication.
- X_AUTH_PASSWORD: Set your customer password for authentication.
- FILE_PATHS: Define the paths to the files you want to upload. You can add or remove file paths as needed, ensuring the numbering is sequential starting from
[0].
Execution
- Save the Script: Save the script as
Save the following script asyour-script-name.bat`. - Open Command Prompt: Navigate to the directory containing the script.
- Run the Script: Execute the script by entering
customer-upload.batin the Command Prompt.
Output
The script will upload each file listed in the FILE_PATHS array to the API endpoint specified. After each upload, the response from the server will be displayed in the Command Prompt window.