1010from rich .progress import Progress , TaskID
1111
1212from dvuploader .file import File
13- from dvuploader .utils import build_url , init_logging , wait_for_dataset_unlock
13+ from dvuploader .utils import init_logging , wait_for_dataset_unlock
1414
1515TESTING = bool (os .environ .get ("DVUPLOADER_TESTING" , False ))
1616MAX_FILE_DISPLAY = int (os .environ .get ("DVUPLOADER_MAX_FILE_DISPLAY" , 50 ))
@@ -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 ,
@@ -205,14 +215,17 @@ async def _request_ticket(
205215 Returns:
206216 Dict: Upload ticket containing URL and storage identifier.
207217 """
208- url = build_url (
209- endpoint = urljoin (dataverse_url , TICKET_ENDPOINT ),
210- key = api_token ,
211- persistentId = persistent_id ,
212- size = file_size ,
218+ response = await session .get (
219+ TICKET_ENDPOINT ,
220+ timeout = None ,
221+ params = {
222+ "size" : file_size ,
223+ "persistentId" : persistent_id ,
224+ },
225+ headers = {
226+ "X-Dataverse-key" : api_token ,
227+ },
213228 )
214-
215- response = await session .get (url , timeout = None )
216229 response .raise_for_status ()
217230
218231 return response .json ()["data" ]
0 commit comments