aliyun_oss_rs/object/
multipart_abort_upload.rs

1use crate::{
2    error::{Error, normal_error},
3    request::{Oss, OssRequest},
4};
5use http::Method;
6
7/// Abort a multipart upload
8///
9/// See the [Alibaba Cloud documentation](https://help.aliyun.com/document_detail/31996.html) for details
10pub struct AbortUpload {
11    req: OssRequest,
12}
13
14impl AbortUpload {
15    pub(super) fn new(oss: Oss, upload_id: impl ToString) -> Self {
16        let mut req = OssRequest::new(oss, Method::DELETE);
17        req.insert_query("uploadId", upload_id);
18        AbortUpload { req }
19    }
20    /// Abort the multipart upload
21    ///
22    pub async fn send(self) -> Result<(), Error> {
23        // Upload file
24        let response = self.req.send_to_oss()?.await?;
25        // Parse the response
26        let status_code = response.status();
27        match status_code {
28            code if code.is_success() => Ok(()),
29            _ => Err(normal_error(response).await),
30        }
31    }
32}