Xuanwo commented on code in PR #7212:
URL: https://github.com/apache/opendal/pull/7212#discussion_r2838732020


##########
core/services/swift/src/core.rs:
##########
@@ -233,6 +234,145 @@ impl SwiftCore {
 
         self.info.http_client().send(req).await
     }
+
+    /// Build the segment path for an SLO part.
+    ///
+    /// Segments are stored as: 
`.segments/{object_path}/{upload_id}/{part_number:08}`
+    pub fn slo_segment_path(&self, path: &str, upload_id: &str, part_number: 
usize) -> String {
+        let abs = build_abs_path(&self.root, path);
+        format!(
+            ".segments/{}{}/{:08}",

Review Comment:
   Is the path defined by Swift, or did we choose it ourselves? Will this path 
be listed out by users?



##########
core/services/swift/src/core.rs:
##########
@@ -233,6 +234,145 @@ impl SwiftCore {
 
         self.info.http_client().send(req).await
     }
+
+    /// Build the segment path for an SLO part.
+    ///
+    /// Segments are stored as: 
`.segments/{object_path}/{upload_id}/{part_number:08}`
+    pub fn slo_segment_path(&self, path: &str, upload_id: &str, part_number: 
usize) -> String {
+        let abs = build_abs_path(&self.root, path);
+        format!(
+            ".segments/{}{}/{:08}",
+            abs.trim_end_matches('/'),
+            upload_id,
+            part_number
+        )
+    }
+
+    /// Upload a segment for an SLO multipart upload.
+    ///
+    /// Reference: 
<https://docs.openstack.org/swift/latest/overview_large_objects.html>
+    pub async fn swift_put_segment(
+        &self,
+        path: &str,
+        upload_id: &str,
+        part_number: usize,
+        size: u64,
+        body: Buffer,
+    ) -> Result<Response<Buffer>> {
+        let segment = self.slo_segment_path(path, upload_id, part_number);
+        let url = format!(
+            "{}/{}/{}",
+            &self.endpoint,
+            &self.container,
+            percent_encode_path(&segment)
+        );
+
+        let mut req = Request::put(&url);
+        req = req.header("X-Auth-Token", &self.token);
+        req = req.header(header::CONTENT_LENGTH, size);
+
+        let req = req
+            .extension(Operation::Write)
+            .body(body)
+            .map_err(new_request_build_error)?;
+
+        self.info.http_client().send(req).await
+    }
+
+    /// Finalize an SLO by uploading the manifest.
+    ///
+    /// PUT {container}/{path}?multipart-manifest=put with a JSON body listing
+    /// each segment's path, etag, and size.
+    ///
+    /// Reference: 
<https://docs.openstack.org/swift/latest/overview_large_objects.html>
+    pub async fn swift_put_slo_manifest(

Review Comment:
   I'm guessing we need to carry the user metadata here?



-- 
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]

Reply via email to