You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by "wlinna (via GitHub)" <gi...@apache.org> on 2025/06/10 04:19:22 UTC
[PR] fix(gcs): headers missing in XML multipart API and incorrect x-goog-acl header values in XML API [opendal]
wlinna opened a new pull request, #6275:
URL: https://github.com/apache/opendal/pull/6275
# Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and enhancements. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
-->
Primarily – fix the issue reported in:
https://discord.com/channels/1081052318650339399/1081052319342407715/1380046336434503780
Secondarily:
Closes https://github.com/apache/opendal/issues/5612.
# Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
-->
OpenDAL's Gcs service currently does not write headers when doing multipart XML uploads. It also does not handle predefined ACLs correctly in the XML API.
# What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
-->
- Adds headers and metadata to XML multipart upload requests
- Converts predefined ACL to the format used in XML API (e.g. "publicRead" -> "public-read") when necessary
# Are there any user-facing changes?
No user-facing changes (unless they depend on broken behavior)
<!--
If there are user-facing changes then we may require documentation to be updated before approving the PR.
-->
<!---
If there are any breaking changes to public APIs, please add the `breaking-changes` label.
-->
--
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: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(gcs): headers missing in XML multipart API and incorrect x-goog-acl header values in XML API [opendal]
Posted by "wlinna (via GitHub)" <gi...@apache.org>.
wlinna commented on code in PR #6275:
URL: https://github.com/apache/opendal/pull/6275#discussion_r2137050171
##########
core/src/services/gcs/core.rs:
##########
@@ -370,7 +372,11 @@ impl GcsCore {
}
if let Some(acl) = &self.predefined_acl {
- req = req.header(X_GOOG_ACL, acl);
+ if let Some(predefined_acl_in_xml_spec) = predefined_acl_to_xml_header(acl) {
+ req = req.header(X_GOOG_ACL, predefined_acl_in_xml_spec);
+ } else {
+ eprintln!("Unrecognized predefined_acl. Ignoring");
Review Comment:
Yeah that's what I wanted to do actually
--
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: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(gcs): headers missing in XML multipart API and incorrect x-goog-acl header values in XML API [opendal]
Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on code in PR #6275:
URL: https://github.com/apache/opendal/pull/6275#discussion_r2136971119
##########
core/src/services/gcs/core.rs:
##########
@@ -370,7 +372,11 @@ impl GcsCore {
}
if let Some(acl) = &self.predefined_acl {
- req = req.header(X_GOOG_ACL, acl);
+ if let Some(predefined_acl_in_xml_spec) = predefined_acl_to_xml_header(acl) {
+ req = req.header(X_GOOG_ACL, predefined_acl_in_xml_spec);
+ } else {
+ eprintln!("Unrecognized predefined_acl. Ignoring");
Review Comment:
Having `eprintln` in a lib like opendal can be really annoying. How about changing it to `log::warn!()` instead?
##########
core/src/services/gcs/core.rs:
##########
@@ -561,14 +567,50 @@ impl GcsCore {
self.send(req).await
}
- pub async fn gcs_initiate_multipart_upload(&self, path: &str) -> Result<Response<Buffer>> {
+ pub async fn gcs_initiate_multipart_upload(
+ &self,
+ path: &str,
+ op: &OpWrite,
+ ) -> Result<Response<Buffer>> {
let p = build_abs_path(&self.root, path);
let url = format!("{}/{}/{}?uploads", self.endpoint, self.bucket, p);
- let mut req = Request::post(&url)
+ let mut builder = Request::post(&url)
.header(CONTENT_LENGTH, 0)
- .extension(Operation::Write)
+ .extension(Operation::Write);
+
+ if let Some(header_val) = op.content_disposition() {
+ builder = builder.header(CONTENT_DISPOSITION, header_val);
+ }
+
+ if let Some(header_val) = op.content_encoding() {
+ builder = builder.header(CONTENT_ENCODING, header_val);
+ }
+
+ if let Some(header_val) = op.content_type() {
+ builder = builder.header(CONTENT_TYPE, header_val);
+ }
+
+ if let Some(header_val) = op.cache_control() {
+ builder = builder.header(CACHE_CONTROL, header_val);
+ }
+
+ if let Some(metadata) = op.user_metadata() {
+ for (k, v) in metadata {
+ builder = builder.header(&format!("x-goog-meta-{k}"), v);
+ }
+ }
+
+ if let Some(acl) = self.predefined_acl.as_ref() {
+ if let Some(predefined_acl_in_xml_spec) = predefined_acl_to_xml_header(acl) {
+ builder = builder.header(X_GOOG_ACL, predefined_acl_in_xml_spec);
+ } else {
+ eprintln!("Unrecognized predefined_acl. Ignoring");
Review Comment:
The same.
--
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: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(gcs): headers missing in XML multipart API and incorrect x-goog-acl header values in XML API [opendal]
Posted by "wlinna (via GitHub)" <gi...@apache.org>.
wlinna commented on code in PR #6275:
URL: https://github.com/apache/opendal/pull/6275#discussion_r2137050171
##########
core/src/services/gcs/core.rs:
##########
@@ -370,7 +372,11 @@ impl GcsCore {
}
if let Some(acl) = &self.predefined_acl {
- req = req.header(X_GOOG_ACL, acl);
+ if let Some(predefined_acl_in_xml_spec) = predefined_acl_to_xml_header(acl) {
+ req = req.header(X_GOOG_ACL, predefined_acl_in_xml_spec);
+ } else {
+ eprintln!("Unrecognized predefined_acl. Ignoring");
Review Comment:
Yeah that's what I wanted to do actually. I will change this
--
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: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(gcs): headers missing in XML multipart API and incorrect x-goog-acl header values in XML API [opendal]
Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo merged PR #6275:
URL: https://github.com/apache/opendal/pull/6275
--
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: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org