@@ -118,14 +118,21 @@ fn do_upload<R: std::io::Read + Send + 'static>(
118118 content_type : & str ,
119119 reader : R ,
120120 pb : ProgressBar ,
121+ content_length : Option < u64 > ,
121122) -> String {
122123 let url = format ! ( "{api_url}/files" ) ;
123124
124- let resp = match client
125+ let mut req = client
125126 . post ( & url)
126127 . header ( "Authorization" , format ! ( "Bearer {api_key}" ) )
127128 . header ( "X-Workspace-Id" , workspace_id)
128- . header ( "Content-Type" , content_type)
129+ . header ( "Content-Type" , content_type) ;
130+
131+ if let Some ( len) = content_length {
132+ req = req. header ( "Content-Length" , len) ;
133+ }
134+
135+ let resp = match req
129136 . body ( reqwest:: blocking:: Body :: new ( reader) )
130137 . send ( )
131138 {
@@ -190,7 +197,7 @@ fn upload_from_file(
190197 let pb = make_progress_bar ( file_size) ;
191198 let reader = pb. wrap_read ( f) ;
192199
193- let id = do_upload ( client, api_key, workspace_id, api_url, ft. content_type , reader, pb) ;
200+ let id = do_upload ( client, api_key, workspace_id, api_url, ft. content_type , reader, pb, Some ( file_size ) ) ;
194201 ( id, ft. format )
195202}
196203
@@ -216,7 +223,7 @@ fn upload_from_stdin(
216223 pb. enable_steady_tick ( std:: time:: Duration :: from_millis ( 80 ) ) ;
217224 let reader = pb. wrap_read ( reader) ;
218225
219- let id = do_upload ( client, api_key, workspace_id, api_url, ft. content_type , reader, pb) ;
226+ let id = do_upload ( client, api_key, workspace_id, api_url, ft. content_type , reader, pb, None ) ;
220227 ( id, ft. format )
221228}
222229
0 commit comments