Xuanwo commented on code in PR #5428:
URL: https://github.com/apache/opendal/pull/5428#discussion_r1957536092
##########
core/src/services/s3/core.rs:
##########
@@ -441,55 +491,44 @@ impl S3Core {
let mut req = Request::put(&url);
- if let Some(size) = size {
- req = req.header(CONTENT_LENGTH, size.to_string())
- }
+ req = self.insert_metadata_headers(req, size, args);
- if let Some(mime) = args.content_type() {
- req = req.header(CONTENT_TYPE, mime)
- }
+ // Set SSE headers.
+ req = self.insert_sse_headers(req, true);
- if let Some(pos) = args.content_disposition() {
- req = req.header(CONTENT_DISPOSITION, pos)
+ // Calculate Checksum.
+ if let Some(checksum) = self.calculate_checksum(&body) {
+ // Set Checksum header.
+ req = self.insert_checksum_header(req, &checksum);
}
- if let Some(encoding) = args.content_encoding() {
- req = req.header(CONTENT_ENCODING, encoding);
- }
+ // Set body
+ let req = req.body(body).map_err(new_request_build_error)?;
- if let Some(cache_control) = args.cache_control() {
- req = req.header(CACHE_CONTROL, cache_control)
- }
+ Ok(req)
+ }
- if let Some(if_match) = args.if_match() {
- req = req.header(IF_MATCH, if_match);
- }
+ pub fn s3_append_object_request(
+ &self,
+ path: &str,
+ position: u64,
+ size: u64,
+ args: &OpWrite,
+ body: Buffer,
+ ) -> Result<Request<Buffer>> {
+ let p = build_abs_path(&self.root, path);
- if args.if_not_exists() {
- req = req.header(IF_NONE_MATCH, "*");
- }
+ let url = format!("{}/{}", self.endpoint, percent_encode_path(&p));
- // Set storage class header
- if let Some(v) = &self.default_storage_class {
- req =
req.header(HeaderName::from_static(constants::X_AMZ_STORAGE_CLASS), v);
- }
+ let mut req = Request::put(&url);
- // Set user metadata headers.
- if let Some(user_metadata) = args.user_metadata() {
- for (key, value) in user_metadata {
- req = req.header(format!("{X_AMZ_META_PREFIX}{key}"), value)
- }
- }
+ req = self.insert_metadata_headers(req, Some(size), args);
Review Comment:
> I may not follow what you mean but it seems we could set up the metadata
after the first one?
Hi, from my current understanding, only the first append request can set
metadata such as `content-type` and `x-amz-meta-abc`. Any metadata-related
parameters in subsequent append requests will be ignored. That means that we
can avoid sending those params in the subsequent append requests to save some
extra bytes on the wire.
--
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]