@@ -327,59 +327,19 @@ fn finish_upload(
327327 size : Option < u64 > ,
328328 pb : & ProgressBar ,
329329) -> String {
330- // The streaming `/files` upload stays on the slim raw-HTTP helper: it
331- // needs no request timeout (a 10 GB+ parquet far outlives the seam's
332- // 300s default), is one-shot (no 401-retry — the body is consumed on the
333- // first send), and the SDK's `uploads().upload` is `PathBuf`-only with no
334- // progress hook or `--url` source. We still carry the same
335- // `Authorization: Bearer <jwt>` (resolved through the seam's installed
336- // token provider) and `X-Workspace-Id` header every other call uses.
337- let upload_client = crate :: raw_http:: build_upload_client ( ) ;
338- let url = format ! ( "{}/files" , api. api_url) ;
339- let mut req = upload_client
340- . post ( & url)
341- . header ( "Content-Type" , "application/octet-stream" ) ;
342- if let Some ( bearer) = api. current_bearer ( ) {
343- req = req. header ( "Authorization" , format ! ( "Bearer {bearer}" ) ) ;
344- }
345- if let Some ( ws) = api. workspace_id ( ) {
346- req = req. header ( "X-Workspace-Id" , ws) ;
347- }
348- if let Some ( len) = size {
349- req = req. header ( "Content-Length" , len) ;
350- }
351- let req = req. body ( reqwest:: blocking:: Body :: new ( reader) ) ;
352-
353- // Body is an opaque stream, so pass `None` for logging; headers
354- // (including the masked Authorization) still log.
355- let ( status, resp_body) = match crate :: util:: send_debug ( & upload_client, req, None ) {
356- Ok ( pair) => pair,
357- Err ( e) => {
358- eprintln ! ( "error connecting to API: {e}" ) ;
359- std:: process:: exit ( 1 ) ;
360- }
361- } ;
330+ // Stream the body to `POST /v1/files` through the SDK seam, which drives the
331+ // SDK's `upload_stream` on a dedicated no-timeout client (a 10 GB+ parquet
332+ // far outlives the shared 300s request timeout) and bridges this blocking,
333+ // progress-wrapped `reader` into the async byte stream the SDK consumes.
334+ // `size` becomes the `Content-Length` so the server fast-fails an oversized
335+ // upload before writing bytes; the `--url` source may not know it, hence
336+ // `Option`. Carries the same auth + scope headers as every other SDK call.
337+ let result = api. upload_stream ( reader, size) ;
362338 pb. finish_and_clear ( ) ;
363339
364- if !status. is_success ( ) {
365- use crossterm:: style:: Stylize ;
366- eprintln ! ( "{}" , crate :: util:: api_error( resp_body) . red( ) ) ;
367- std:: process:: exit ( 1 ) ;
368- }
369-
370- let body: serde_json:: Value = match serde_json:: from_str ( & resp_body) {
371- Ok ( v) => v,
372- Err ( e) => {
373- eprintln ! ( "error parsing upload response: {e}" ) ;
374- std:: process:: exit ( 1 ) ;
375- }
376- } ;
377- match body[ "id" ] . as_str ( ) {
378- Some ( id) => id. to_string ( ) ,
379- None => {
380- eprintln ! ( "error: upload response missing id" ) ;
381- std:: process:: exit ( 1 ) ;
382- }
340+ match result {
341+ Ok ( id) => id,
342+ Err ( e) => e. exit ( ) ,
383343 }
384344}
385345
0 commit comments