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

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


The following commit(s) were added to refs/heads/main by this push:
     new 88915b93 fix(services/gcs): set `content length=0` for gcs 
initiate_resumable_upload (#2110)
88915b93 is described below

commit 88915b93853803044886fb49ed87aee0e901844e
Author: congyi wang <[email protected]>
AuthorDate: Tue Apr 25 14:22:48 2023 +0800

    fix(services/gcs): set `content length=0` for gcs initiate_resumable_upload 
(#2110)
    
    * gcs content length
    
    * minor fix
---
 core/src/services/gcs/core.rs | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/core/src/services/gcs/core.rs b/core/src/services/gcs/core.rs
index 044d6332..b53fbb78 100644
--- a/core/src/services/gcs/core.rs
+++ b/core/src/services/gcs/core.rs
@@ -172,9 +172,7 @@ impl GcsCore {
 
         let mut req = Request::post(&url);
 
-        if let Some(size) = size {
-            req = req.header(CONTENT_LENGTH, size)
-        }
+        req = req.header(CONTENT_LENGTH, size.unwrap_or_default());
 
         if let Some(storage_class) = &self.default_storage_class {
             req = req.header(CONTENT_TYPE, "multipart/related; 
boundary=my-boundary");
@@ -325,9 +323,12 @@ impl GcsCore {
             "{}/upload/storage/v1/b/{}/o?uploadType=resumable&name={}",
             self.endpoint, self.bucket, p
         );
+
         let mut req = Request::post(&url)
+            .header(CONTENT_LENGTH, 0)
             .body(AsyncBody::Empty)
             .map_err(new_request_build_error)?;
+
         self.sign(&mut req).await?;
         self.send(req).await
     }

Reply via email to