Xuanwo commented on code in PR #1996:
URL: 
https://github.com/apache/incubator-opendal/pull/1996#discussion_r1166753300


##########
core/src/services/gcs/core.rs:
##########
@@ -145,42 +141,50 @@ impl GcsCore {
         let p = build_abs_path(&self.root, path);
 
         let mut url = format!(
-            "{}/upload/storage/v1/b/{}/o?uploadType=multipart&name={}",
+            "{}/upload/storage/v1/b/{}/o?uploadType={}&name={}",
             self.endpoint,
             self.bucket,
+            if self.default_storage_class.is_some() {
+                "multipart"
+            } else {
+                "media"
+            },
             percent_encode_path(&p)
         );
 
         if let Some(acl) = &self.predefined_acl {
             write!(&mut url, "&predefinedAcl={}", acl).unwrap();
         }
 
-        let mut req =
-            Request::post(&url).header(CONTENT_TYPE, "multipart/related; 
boundary=my-boundary");
+        let mut req = Request::post(&url);
 
         if let Some(size) = size {
             req = req.header(CONTENT_LENGTH, size)
         }
 
-        let mut req_body = BytesMut::with_capacity(100);
-        write!(
-            &mut req_body,
-            "--my-boundary\nContent-Type: application/json; 
charset=UTF-8\n\n{{\"storageClass\": \"{}\"}}\n\n--my-boundary\n",
-            self.default_storage_class
-        ).unwrap();
-
         if let Some(mime) = content_type {
-            write!(&mut req_body, "Content-Type: {}\n\n", mime).unwrap();
-        } else {
-            write!(&mut req_body, "Content-Type: 
application/octet-stream\n\n").unwrap();
+            req = req.header(CONTENT_TYPE, mime);
         }
 
-        if let AsyncBody::Bytes(bytes) = body {
-            req_body.extend_from_slice(&bytes);
+        let mut body = body;
+
+        if let Some(storage_class) = &self.default_storage_class {
+            let json = format!(r#"{{"storageClass": "{}"}}"#, storage_class);
+
+            match body {
+                AsyncBody::Empty => {
+                    body = AsyncBody::Multipart(json, Bytes::new());

Review Comment:
   Sorry for my mistake. My previous review is wrong and reqwest can't build a 
`multipart/related` body. Please rollback to the previous version. We can add 
this feature first and than polish it in the future.
   
   Sorry again for my mistake.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to