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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]