Skip to content

Commit ec3bbf9

Browse files
committed
fixes for the user flow
1 parent 87181c3 commit ec3bbf9

2 files changed

Lines changed: 19 additions & 7 deletions

File tree

295 KB
Binary file not shown.

examples/Workspaces/eg002AddDocumentToWorkspace.sh

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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
4243
while 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 ""
@@ -63,19 +64,30 @@ done
6364

6465
# Enter the document name for the workspace
6566
echo ""
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):"
6768
echo ""
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
7487
Status=$(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

Comments
 (0)