@@ -35,17 +35,18 @@ declare -a Headers=(
3535)
3636# ds-snippet-end:Workspaces2Step2
3737
38- DOCUMENTS_DIR=" demo_documents"
38+ SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
39+ DEMO_DOCS_PATH=" $( cd " $SCRIPT_DIR /../../demo_documents" && pwd) "
3940
4041# Upload the file path to be added to the workspace
4142# ds-snippet-start:Workspaces2Step3
4243while true ; do
4344 echo " "
44- echo " Enter the PDF file name (e.g. World_Wide_Corp_Web_Form.pdf) from the demo_documents folder:"
45+ echo " Enter the PDF file name (e.g. World_Wide_Corp_Web_Form.pdf) from the ${DEMO_DOCS_PATH} folder:"
4546 echo " "
4647 read file_name
4748
48- file_path=" $DOCUMENTS_DIR /$file_name "
49+ file_path=" $DEMO_DOCS_PATH /$file_name "
4950
5051 if [[ " $file_name " != * .pdf ]]; then
5152 echo " "
6364
6465# Enter the document name for the workspace
6566echo " "
66- echo " Enter the name for the document in the workspace:"
67+ echo " Enter the name for the document in the workspace (must end with .pdf) :"
6768echo " "
6869
69- read doc_name
70+ while true ; do
71+ read doc_name
72+
73+ doc_name=$( echo " $doc_name " | xargs)
74+
75+ if [[ " $doc_name " =~ \. pdf$ ]]; then
76+ break
77+ else
78+ echo " "
79+ echo " Invalid name. The document name must end with '.pdf' (e.g., example.pdf)."
80+ echo " Please try again:"
81+ fi
82+ done
7083# ds-snippet-end:Workspaces2Step3
7184
7285# apx-snippet-start:addWorkspaceDocument
7386# ds-snippet-start:Workspaces2Step4
7487Status=$( curl -s -w " %{http_code}" -o " ${response} " \
7588 --request POST " ${base_path} /accounts/${account_id} /workspaces/${workspace_id} /documents" \
7689 " ${Headers[@]} " \
77- -F " file=@${file_path} " \
78- -F " name=${doc_name} "
90+ -F " file=@${file_path} ;filename=${doc_name} " \
7991)
8092# ds-snippet-end:Workspaces2Step4
8193# apx-snippet-end:addWorkspaceDocument
0 commit comments