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


##########
core/src/types/operator/operator.rs:
##########
@@ -1964,4 +1964,133 @@ impl Operator {
             },
         )
     }
+
+    /// Presign an operation for delete.
+    ///
+    /// # Notes
+    ///
+    /// ## Extra Options
+    ///
+    /// `presign_delete` is a wrapper of [`Self::presign_delete_with`] without 
any options. To use
+    /// extra options like `content_type`, please use 
[`Self::presign_delete_with`] instead.
+    ///
+    /// # Example
+    ///
+    /// ```
+    /// use std::time::Duration;
+    ///
+    /// use anyhow::Result;
+    /// use opendal::Operator;
+    ///
+    /// async fn test(op: Operator) -> Result<()> {
+    ///     let signed_req = op
+    ///         .presign_delete("test.txt", Duration::from_secs(3600))
+    ///         .await?;
+    ///     Ok(())
+    /// }
+    /// ```
+    ///
+    /// - `signed_req.method()`: `PUT`
+    /// - `signed_req.uri()`: 
`https://s3.amazonaws.com/examplebucket/test.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=access_key_id/20130721/us-east-1/s3/aws4_request&X-Amz-Date=20130721T201207Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=<signature-value>`
+    /// - `signed_req.headers()`: `{ "host": "s3.amazonaws.com" }`
+    ///
+    /// We can upload file as this file via `curl` or other tools without 
credential:
+    ///
+    /// ```shell
+    /// curl -X PUT 
"https://s3.amazonaws.com/examplebucket/test.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=access_key_id/20130721/us-east-1/s3/aws4_request&X-Amz-Date=20130721T201207Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=<signature-value>"
 -d "Hello, World!"

Review Comment:
   This should be `DELETE`.



##########
core/src/docs/rfcs/0413_presign.md:
##########


Review Comment:
   old rfcs don't need to change.



##########
core/src/types/operator/operator.rs:
##########
@@ -1964,4 +1964,133 @@ impl Operator {
             },
         )
     }
+
+    /// Presign an operation for delete.
+    ///
+    /// # Notes
+    ///
+    /// ## Extra Options
+    ///
+    /// `presign_delete` is a wrapper of [`Self::presign_delete_with`] without 
any options. To use

Review Comment:
   delete doesn't support setting `content_type`.



##########
core/src/services/s3/backend.rs:
##########
@@ -1111,6 +1112,7 @@ impl Access for S3Backend {
                 self.core
                     .s3_put_object_request(path, None, &OpWrite::default(), 
Buffer::new())?
             }
+            PresignOperation::Delete(_) => todo!(),

Review Comment:
   Implementing it for S3 first is a good starting point for me.



##########
core/src/services/cos/backend.rs:
##########
@@ -428,6 +429,7 @@ impl Access for CosBackend {
                 self.core
                     .cos_put_object_request(path, None, v, Buffer::new())?
             }
+            PresignOperation::Delete(v) => todo!(),

Review Comment:
   No need; we can implement them gradually and across multiple PRs.



##########
core/tests/behavior/async_presign.rs:
##########
@@ -138,3 +139,9 @@ pub async fn test_presign_read(op: Operator) -> Result<()> {
     op.delete(&path).await.expect("delete must succeed");
     Ok(())
 }
+
+/// Presign delete should succeed.
+pub async fn test_presign_delete(op: Operator) -> Result<()> {
+    todo!();

Review Comment:
   Like we do in `test_presign_read`, we can create a file and send a `DELETE` 
request to the returning uri.



##########
core/src/types/operator/operator.rs:
##########
@@ -1964,4 +1964,133 @@ impl Operator {
             },
         )
     }
+
+    /// Presign an operation for delete.
+    ///
+    /// # Notes
+    ///
+    /// ## Extra Options
+    ///
+    /// `presign_delete` is a wrapper of [`Self::presign_delete_with`] without 
any options. To use
+    /// extra options like `content_type`, please use 
[`Self::presign_delete_with`] instead.
+    ///
+    /// # Example
+    ///
+    /// ```
+    /// use std::time::Duration;
+    ///
+    /// use anyhow::Result;
+    /// use opendal::Operator;
+    ///
+    /// async fn test(op: Operator) -> Result<()> {
+    ///     let signed_req = op
+    ///         .presign_delete("test.txt", Duration::from_secs(3600))
+    ///         .await?;
+    ///     Ok(())
+    /// }
+    /// ```
+    ///
+    /// - `signed_req.method()`: `PUT`

Review Comment:
   The same. Please avoid copying comments without reviewing.



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