Xuanwo commented on code in PR #1996:
URL:
https://github.com/apache/incubator-opendal/pull/1996#discussion_r1166682483
##########
core/src/services/gcs/backend.rs:
##########
@@ -115,6 +118,7 @@ pub struct GcsBuilder {
http_client: Option<HttpClient>,
customed_token_loader: Option<Box<dyn GoogleTokenLoad>>,
predefined_acl: Option<String>,
+ default_storage_class: String,
Review Comment:
How about using `Option<String>` to distinguish between `None` and
`Some("")`?
##########
core/src/services/gcs/backend.rs:
##########
@@ -218,6 +222,20 @@ impl GcsBuilder {
};
self
}
+
+ /// Set the default storage class for GCS.
Review Comment:
Nice docs!
##########
core/src/services/gcs/core.rs:
##########
@@ -46,15 +47,20 @@ pub struct GcsCore {
pub credential_loader: GoogleCredentialLoader,
pub predefined_acl: Option<String>,
+ pub default_storage_class: String,
}
impl Debug for GcsCore {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
let mut de = f.debug_struct("Backend");
de.field("endpoint", &self.endpoint)
.field("bucket", &self.bucket)
- .field("root", &self.root)
- .finish_non_exhaustive()
+ .field("root", &self.root);
+ if self.predefined_acl.is_some() {
Review Comment:
We can ignore this part.
##########
core/src/services/gcs/core.rs:
##########
@@ -149,19 +155,32 @@ impl GcsCore {
write!(&mut url, "&predefinedAcl={}", acl).unwrap();
}
- let mut req = Request::post(&url);
+ let mut req =
+ Request::post(&url).header(CONTENT_TYPE, "multipart/related;
boundary=my-boundary");
Review Comment:
I don't feel comfortable with handwriting multipart request. How about using
`request` multipart support? We can extend `AsyncBody`'s Multipart to allow
multiple fields.
Example could be found at
https://github.com/apache/incubator-opendal/blob/main/core/src/services/ipmfs/writer.rs#L44
##########
core/src/services/gcs/core.rs:
##########
@@ -139,7 +145,7 @@ impl GcsCore {
let p = build_abs_path(&self.root, path);
let mut url = format!(
- "{}/upload/storage/v1/b/{}/o?uploadType=media&name={}",
+ "{}/upload/storage/v1/b/{}/o?uploadType=multipart&name={}",
Review Comment:
We can still use `meida` if `storage_class` not set.
--
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]