Skip to content

Commit c81d93c

Browse files
committed
2 parents 4167c47 + 26c1e96 commit c81d93c

7 files changed

Lines changed: 147 additions & 3 deletions

File tree

OAuth/code_grant.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
elseif($api_version == "Maestro") :
3232
$scope = "signature aow_manage";
3333
elseif($api_version == "Navigator") :
34-
$scope = "signature adm_store_unified_repo_read";
34+
$scope = "signature adm_store_unified_repo_read document_uploader_write document_uploader_read";
3535
elseif($api_version == "Workspaces") :
3636
$scope = "signature impersonation dtr.company.read dtr.rooms.read dtr.rooms.write dtr.documents.write";
3737
endif;

OAuth/jwt.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
} else if ($api_version == "Maestro") {
3535
$scope = "signature aow_manage";
3636
} else if ($api_version == "Navigator") {
37-
$scope = "signature adm_store_unified_repo_read";
37+
$scope = "signature adm_store_unified_repo_read document_uploader_write document_uploader_read";
3838
} else if ($api_version == "ConnectedFields") {
3939
$scope = "signature adm_store_unified_repo_read";
4040
} else if ($api_version == "Workspaces") {

OAuth/jwt_auth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
]
6262

6363
NAVIGATOR_SCOPES = [
64-
"signature", "adm_store_unified_repo_read"
64+
"signature", "adm_store_unified_repo_read document_uploader_write document_uploader_read"
6565
]
6666

6767
CONNECTED_FIELDS_SCOPES = [

demo_documents/Id.jpg

849 KB
Loading

demo_documents/Welcome.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
3+
4+
Welcome to the DocuSign Recruiting Event
5+
6+
7+
Please Sign in!
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# Check that we're in a bash shell
2+
if [[ $SHELL != *"bash"* ]]; then
3+
echo "PROBLEM: Run these scripts from within the bash shell."
4+
fi
5+
6+
# Obtain your OAuth token
7+
ACCESS_TOKEN=$(cat config/ds_access_token.txt)
8+
9+
# Set up variables for full code example
10+
account_id=$(cat config/API_ACCOUNT_ID)
11+
base_path="https://api-d.docusign.com/v1"
12+
13+
request_data=$(mktemp /tmp/request-nav-003.XXXXXX)
14+
response=$(mktemp /tmp/response-nav-003.XXXXXX)
15+
16+
#ds-snippet-start:Navigator3Step2
17+
printf \
18+
'{
19+
"job_name": "Example bulk upload job",
20+
"expected_number_of_docs": 5,
21+
"language": "en-US"
22+
}' >> $request_data
23+
24+
curl --request POST ${base_path}/accounts/${account_id}/upload/jobs \
25+
--header "Authorization: Bearer ${ACCESS_TOKEN}" \
26+
--header "Accept: application/json" \
27+
--header "Content-Type: application/json" \
28+
--data-binary @${request_data} \
29+
--output $response
30+
31+
# Extract job ID and upload URLs for each document
32+
job_id=$(cat "$response" | grep -o '"id":"[^"]*' | head -1 | cut -d'"' -f4)
33+
upload_urls=$(cat $response | grep -o '"upload_document":"[^"]*' | cut -d'"' -f4)
34+
#ds-snippet-end:Navigator3Step2
35+
36+
echo "Created upload job with ID: $job_id"
37+
38+
read -p "Press Enter to upload documents for this job"
39+
40+
echo "Uploading documents..."
41+
echo ""
42+
43+
#ds-snippet-start:Navigator3Step3
44+
# Array of demo documents to upload
45+
declare -a demo_files=(
46+
"demo_documents/World_Wide_Corp_Battle_Plan_Trafalgar.docx"
47+
"demo_documents/World_Wide_Corp_lorem.pdf"
48+
"demo_documents/doc_1.html"
49+
"demo_documents/Welcome.txt"
50+
"demo_documents/Id.jpg"
51+
)
52+
53+
# Convert to array (cross-platform: works on macOS and Linux)
54+
upload_urls_array=()
55+
while IFS= read -r url; do
56+
upload_urls_array+=("$url")
57+
done <<<"$upload_urls"
58+
59+
# Upload each file
60+
for i in "${!demo_files[@]}"; do
61+
file_path="${demo_files[$i]}"
62+
upload_url="${upload_urls_array[$i]}"
63+
64+
# Extract filename from path
65+
filename=$(basename "$file_path")
66+
67+
if [[ ! -f "$file_path" ]]; then
68+
echo "Skipping $filename - file not found: $file_path"
69+
continue
70+
fi
71+
72+
if [[ -z "$upload_url" ]]; then
73+
echo "Skipping $filename - no upload URL found"
74+
continue
75+
fi
76+
77+
case "$filename" in
78+
*.docx)
79+
content_type="application/vnd.openxmlformats-officedocument.wordprocessingml.document"
80+
;;
81+
*.pdf)
82+
content_type="application/pdf"
83+
;;
84+
*.html)
85+
content_type="text/html"
86+
;;
87+
*.txt)
88+
content_type="text/plain"
89+
;;
90+
*.jpg|*.jpeg)
91+
content_type="image/jpeg"
92+
;;
93+
*)
94+
content_type="application/octet-stream"
95+
;;
96+
esac
97+
98+
echo "Uploading $filename..."
99+
100+
101+
# Make PUT request with binary file content and required headers.
102+
curl --request PUT "$upload_url" \
103+
--header "x-ms-blob-type: BlockBlob" \
104+
--header "x-ms-meta-filename: ${filename}" \
105+
--header "Content-Type: ${content_type}" \
106+
--data-binary @"$file_path"
107+
done
108+
#ds-snippet-end:Navigator3Step3
109+
110+
echo ""
111+
read -p "The documents have been uploaded. Press Enter to update the job status."
112+
113+
#ds-snippet-start:Navigator3Step4
114+
curl --request POST "${base_path}/accounts/${account_id}/upload/jobs/${job_id}/actions/complete" \
115+
--header "Authorization: Bearer ${ACCESS_TOKEN}" \
116+
--header "Accept: application/json" \
117+
--header "Content-Type: application/json" \
118+
--output "$response"
119+
#ds-snippet-end:Navigator3Step4
120+
121+
echo ""
122+
echo "Bulk upload job has been completed. Response:"
123+
echo ""
124+
cat "$response"
125+
echo ""
126+
127+
rm -f "$response"
128+
rm -f "$request_data"
129+
130+
echo ""
131+
echo "Done."
132+
echo ""

launcher.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,7 @@ function startNavigator() {
10331033
select CHOICE in \
10341034
"List_Agreements" \
10351035
"Get_Single_Agreement" \
1036+
"Bulk_Upload" \
10361037
"Home"; do
10371038
case "$CHOICE" in
10381039

@@ -1047,6 +1048,10 @@ function startNavigator() {
10471048
bash examples/Navigator/eg002GetSingleAgreement.sh
10481049
startNavigator
10491050
;;
1051+
Bulk_Upload)
1052+
bash examples/Navigator/eg003BulkUpload.sh
1053+
startNavigator
1054+
;;
10501055
*)
10511056
echo "Default action..."
10521057
startNavigator

0 commit comments

Comments
 (0)