You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by si...@apache.org on 2023/08/25 09:30:44 UTC

[incubator-opendal] 01/01: feat(core/raw): support stream body for mixedpart

This is an automated email from the ASF dual-hosted git repository.

silver pushed a commit to branch mixedpart-stream
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git

commit a8503051dd8850dfcc434122532c513ca406eef1
Author: silver-ymz <yi...@gmail.com>
AuthorDate: Fri Aug 25 17:30:29 2023 +0800

    feat(core/raw): support stream body for mixedpart
    
    Signed-off-by: silver-ymz <yi...@gmail.com>
---
 core/src/raw/http_util/multipart.rs | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/core/src/raw/http_util/multipart.rs b/core/src/raw/http_util/multipart.rs
index d890ceed2..edc061c1f 100644
--- a/core/src/raw/http_util/multipart.rs
+++ b/core/src/raw/http_util/multipart.rs
@@ -410,7 +410,15 @@ impl MixedPart {
                 bs.len() as u64,
                 Some(Box::new(oio::Cursor::from(bs)) as Streamer),
             ),
-            AsyncBody::Stream(_) => panic!("multipart request can't contain stream body"),
+            AsyncBody::Stream(stream) => {
+                let len = parts
+                    .headers
+                    .get(CONTENT_LENGTH)
+                    .and_then(|v| v.to_str().ok())
+                    .and_then(|v| v.parse::<u64>().ok())
+                    .expect("the content length of a mixed part must be valid");
+                (len, Some(stream))
+            }
         };
 
         Self {