@@ -138,7 +138,7 @@ async fn upload(
138
138
let mut request = client
139
139
. post ( & url)
140
140
. header ( reqwest:: header:: CONTENT_LENGTH , file_len)
141
- . body ( file_to_body ( on_progress, file) ) ;
141
+ . body ( file_to_body ( on_progress, file, file_len ) ) ;
142
142
143
143
// Loop through the headers keys and values
144
144
// and add them to the request object.
@@ -160,18 +160,18 @@ async fn upload(
160
160
. map_err ( |e| Error :: Io ( std:: io:: Error :: new ( std:: io:: ErrorKind :: Other , e. to_string ( ) ) ) ) ?
161
161
}
162
162
163
- fn file_to_body ( channel : Channel < ProgressPayload > , file : File ) -> reqwest:: Body {
163
+ fn file_to_body ( channel : Channel < ProgressPayload > , file : File , file_len : u64 ) -> reqwest:: Body {
164
164
let stream = FramedRead :: new ( file, BytesCodec :: new ( ) ) . map_ok ( |r| r. freeze ( ) ) ;
165
165
166
166
let mut stats = TransferStats :: default ( ) ;
167
167
reqwest:: Body :: wrap_stream ( ReadProgressStream :: new (
168
168
stream,
169
- Box :: new ( move |progress, total | {
169
+ Box :: new ( move |progress, _total | {
170
170
stats. record_chunk_transfer ( progress as usize ) ;
171
171
let _ = channel. send ( ProgressPayload {
172
172
progress,
173
173
progress_total : stats. total_transferred ,
174
- total,
174
+ total : file_len ,
175
175
transfer_speed : stats. transfer_speed ,
176
176
} ) ;
177
177
} ) ,
0 commit comments