aliyun_oss_rs/object/
put_object_acl.rs

1use crate::{
2    Error,
3    common::Acl,
4    error::normal_error,
5    request::{Oss, OssRequest},
6};
7use http::Method;
8
9/// Set the object's ACL
10///
11/// See the [Alibaba Cloud documentation](https://help.aliyun.com/document_detail/31986.html) for details
12pub struct PutObjectAcl {
13    req: OssRequest,
14}
15impl PutObjectAcl {
16    pub(super) fn new(oss: Oss, acl: Acl) -> Self {
17        let mut req = OssRequest::new(oss, Method::PUT);
18        req.insert_query("acl", "");
19        req.insert_header("x-oss-object-acl", acl);
20        PutObjectAcl { req }
21    }
22    /// Send the request
23    ///
24    pub async fn send(self) -> Result<(), Error> {
25        // Build the HTTP request
26        let response = self.req.send_to_oss()?.await?;
27        // Parse the response
28        let status_code = response.status();
29        match status_code {
30            code if code.is_success() => Ok(()),
31            _ => Err(normal_error(response).await),
32        }
33    }
34}