Skip to content

Commit 961a3a0

Browse files
committed
Add base_url to httpx client and improve progress bar
Set 'base_url' in httpx.AsyncClient for direct uploads to ensure correct request routing. Enhanced progress bar descriptions to indicate singlepart or multipart uploads. Added 'X-Dataverse-key' header in ticket request for authentication.
1 parent 0ac0190 commit 961a3a0

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

dvuploader/directupload.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ async def direct_upload(
6969
"timeout": None,
7070
"limits": httpx.Limits(max_connections=n_parallel_uploads),
7171
"proxy": proxy,
72+
"base_url": dataverse_url,
7273
}
7374

7475
async with httpx.AsyncClient(**session_params) as session:
@@ -106,6 +107,7 @@ async def direct_upload(
106107
"timeout": None,
107108
"limits": httpx.Limits(max_connections=n_parallel_uploads),
108109
"headers": headers,
110+
"base_url": dataverse_url,
109111
}
110112

111113
async with httpx.AsyncClient(**session_params) as session:
@@ -159,6 +161,10 @@ async def _upload_to_store(
159161
)
160162

161163
if "urls" not in ticket:
164+
# Update the progress bar description and append [Singlepart]
165+
progress.update(
166+
pbar, description=f"Uploading file '{file.file_name}' [Singlepart]"
167+
)
162168
status, storage_identifier = await _upload_singlepart(
163169
session=session,
164170
ticket=ticket,
@@ -170,6 +176,10 @@ async def _upload_to_store(
170176
)
171177

172178
else:
179+
# Update the progress bar description and append [Multipart]
180+
progress.update(
181+
pbar, description=f"Uploading file '{file.file_name}' [Multipart]"
182+
)
173183
status, storage_identifier = await _upload_multipart(
174184
session=session,
175185
response=ticket,
@@ -214,6 +224,9 @@ async def _request_ticket(
214224
"size": file_size,
215225
"persistentId": persistent_id,
216226
},
227+
headers={
228+
"X-Dataverse-key": api_token,
229+
},
217230
)
218231
response.raise_for_status()
219232

0 commit comments

Comments
 (0)