diff --git a/plugins/upload/guest-js/index.ts b/plugins/upload/guest-js/index.ts index d2eced4e..26bc93b4 100644 --- a/plugins/upload/guest-js/index.ts +++ b/plugins/upload/guest-js/index.ts @@ -51,6 +51,10 @@ async function upload( }); } +/// Download file from given url. +/// +/// Note that `filePath` currently must include the file name. +/// Furthermore the progress events will report a total length of 0 if the server did not sent a `Content-Length` header or if the file is compressed. async function download( url: string, filePath: string, diff --git a/plugins/upload/src/lib.rs b/plugins/upload/src/lib.rs index 21154e89..c4a0d8c7 100644 --- a/plugins/upload/src/lib.rs +++ b/plugins/upload/src/lib.rs @@ -62,9 +62,7 @@ async fn download( } let response = request.send().await?; - let total = response.content_length().ok_or_else(|| { - Error::ContentLength(format!("Failed to get content length from '{url}'")) - })?; + let total = response.content_length().unwrap_or(0); let mut file = File::create(file_path).await?; let mut stream = response.bytes_stream();