You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by "meteorgan (via GitHub)" <gi...@apache.org> on 2025/03/04 13:05:31 UTC
[I] Implement `Write Returns Metadata` for all services [opendal]
meteorgan opened a new issue, #5693:
URL: https://github.com/apache/opendal/issues/5693
#5562 has implemented all the fundamental elements for `Write Returns Metadata`. Now, we need to extend this feature for every service. This issue will be used to track the progress.
The modification is straightforward -- we just need to add the new `write_with` capabilities and extract metadata from `write` responses.
for example:
```diff
diff --git a/core/src/services/oss/backend.rs b/core/src/services/oss/backend.rs
index 106ee102..a9aa225b 100644
--- a/core/src/services/oss/backend.rs
+++ b/core/src/services/oss/backend.rs
@@ -460,6 +460,8 @@ impl Builder for OssBuilder {
Some(usize::MAX)
},
write_with_user_metadata: true,
+ write_has_etag: true,
+ write_has_version: self.config.enable_versioning,
delete: true,
delete_with_version: self.config.enable_versioning,
@@ -541,7 +543,7 @@ impl Access for OssBackend {
let headers = resp.headers();
let mut meta = self.core.parse_metadata(path, resp.headers())?;
- if let Some(v) = parse_header_to_str(headers, "x-oss-version-id")? {
+ if let Some(v) = parse_header_to_str(headers, constants::X_OSS_VERSION_ID)? {
meta.set_version(v);
}
diff --git a/core/src/services/oss/core.rs b/core/src/services/oss/core.rs
index 185047b2..c88d4806 100644
--- a/core/src/services/oss/core.rs
+++ b/core/src/services/oss/core.rs
@@ -54,6 +54,8 @@ pub mod constants {
pub const X_OSS_FORBID_OVERWRITE: &str = "x-oss-forbid-overwrite";
+ pub const X_OSS_VERSION_ID: &str = "x-oss-version-id";
+
pub const RESPONSE_CONTENT_DISPOSITION: &str = "response-content-disposition";
pub const OSS_QUERY_VERSION_ID: &str = "versionId";
diff --git a/core/src/services/oss/writer.rs b/core/src/services/oss/writer.rs
index 847a93c0..7ddb69ba 100644
--- a/core/src/services/oss/writer.rs
+++ b/core/src/services/oss/writer.rs
@@ -17,7 +17,7 @@
use std::sync::Arc;
-use http::StatusCode;
+use http::{HeaderMap, HeaderValue, StatusCode};
use super::core::*;
use super::error::parse_error;
@@ -41,6 +41,21 @@ impl OssWriter {
op,
}
}
+
+ fn parse_metadata(headers: &HeaderMap<HeaderValue>) -> Result<Metadata> {
+ let mut meta = Metadata::default();
+ if let Some(etag) = parse_etag(headers)? {
+ meta.set_etag(etag);
+ }
+ if let Some(md5) = parse_content_md5(headers)? {
+ meta.set_content_md5(md5);
+ }
+ if let Some(version) = parse_header_to_str(headers, constants::X_OSS_VERSION_ID)? {
+ meta.set_version(version);
+ }
+
+ Ok(meta)
+ }
}
impl oio::MultipartWrite for OssWriter {
@@ -53,10 +68,11 @@ impl oio::MultipartWrite for OssWriter {
let resp = self.core.send(req).await?;
+ let meta = Self::parse_metadata(resp.headers())?;
let status = resp.status();
match status {
- StatusCode::CREATED | StatusCode::OK => Ok(Metadata::default()),
+ StatusCode::CREATED | StatusCode::OK => Ok(meta),
_ => Err(parse_error(resp)),
}
}
@@ -145,10 +161,11 @@ impl oio::MultipartWrite for OssWriter {
.oss_complete_multipart_upload_request(&self.path, upload_id, false, parts)
.await?;
+ let meta = Self::parse_metadata(resp.headers())?;
let status = resp.status();
match status {
- StatusCode::OK => Ok(Metadata::default()),
+ StatusCode::OK => Ok(meta),
_ => Err(parse_error(resp)),
}
}
@@ -198,10 +215,11 @@ impl oio::AppendWrite for OssWriter {
let resp = self.core.send(req).await?;
+ let meta = Self::parse_metadata(resp.headers())?;
let status = resp.status();
match status {
- StatusCode::OK => Ok(Metadata::default()),
+ StatusCode::OK => Ok(meta),
_ => Err(parse_error(resp)),
}
}
```
The whole change could be seen at: #5688
**Note**: we don't need to add the `write_has_content_length` capability, as it's enabled by default. However, if `content_length` field is provided, we still need to parse and include it in the metadata.
### Services
- [ ] S3
- [ ] aliyun_drive
- [ ] alluxio
- [ ] atomicserver
- [ ] azblob
- [ ] azdls
- [ ] azfile
- [ ] b2
- [ ] comfs
- [ ] cos
- [ ] dbfs
- [ ] dropbox
- [ ] foundationdb
- [ ] fs
- [ ] ftp
- [ ] gcs
- [ ] gdrive
- [ ] ghac
- [ ] github
- [ ] gridfs
- [ ] hdfs
- [ ] hdfs_native
- [ ] http
- [ ] icloud
- [ ] onedrive
- [ ] oss
- [ ] seafile
- [ ] sftp
- [ ] webdav
- [ ] webhdfs
- [ ] yandex_disk
--
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.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Implement `Write Returns Metadata` for all services [opendal]
Posted by "rich7420 (via GitHub)" <gi...@apache.org>.
rich7420 commented on issue #5693:
URL: https://github.com/apache/opendal/issues/5693#issuecomment-3588507022
It seems we don’t get any metadata in the upload response if we don’t add the ret-json parameter to the request.
https://cloud.seafile.com/published/web-api/v2.1/file-upload.md
So we don't need to write returns metadata for seafile.
--
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: [I] Implement `Write Returns Metadata` for all services [opendal]
Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on issue #5693:
URL: https://github.com/apache/opendal/issues/5693#issuecomment-3542205381
> Hello, could I try this PR? thanks!
Feel free to take it!
--
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: [I] Implement `Write Returns Metadata` for all services [opendal]
Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on issue #5693:
URL: https://github.com/apache/opendal/issues/5693#issuecomment-3043964455
> Hi, is this issue still open for PRs? I'd like to work on the FTP feature.
Feel free to go, but I don't know what metadata that FTP can return.
--
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: [I] Implement `Write Returns Metadata` for all services [opendal]
Posted by "meteorgan (via GitHub)" <gi...@apache.org>.
meteorgan commented on issue #5693:
URL: https://github.com/apache/opendal/issues/5693#issuecomment-2778891257
#5933 isn't a suitable example. I'll implement this feature for `azblob` as a demonstration instead.
--
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: [I] Implement `Write Returns Metadata` for all services [opendal]
Posted by "meteorgan (via GitHub)" <gi...@apache.org>.
meteorgan commented on issue #5693:
URL: https://github.com/apache/opendal/issues/5693#issuecomment-2766257393
Now that the changes from #5908 are in place, I'll update this issue later.
--
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: [I] Implement `Write Returns Metadata` for all services [opendal]
Posted by "rich7420 (via GitHub)" <gi...@apache.org>.
rich7420 commented on issue #5693:
URL: https://github.com/apache/opendal/issues/5693#issuecomment-3542112119
Hello, could I try this PR as well? thanks!
--
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: [I] Implement `Write Returns Metadata` for all services [opendal]
Posted by "pmupkin (via GitHub)" <gi...@apache.org>.
pmupkin commented on issue #5693:
URL: https://github.com/apache/opendal/issues/5693#issuecomment-3043926513
Hi, is this issue still open for PRs? I'd like to work on the FTP feature.
--
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: [I] Implement `Write Returns Metadata` for all services [opendal]
Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo closed issue #5693: Implement `Write Returns Metadata` for all services
URL: https://github.com/apache/opendal/issues/5693
--
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