azure_storage_blobs/blob/operations/
put_append_blob.rs1use crate::prelude::*;
2use azure_core::{headers::*, prelude::*, RequestId};
3use time::OffsetDateTime;
4
5operation! {
6 PutAppendBlob,
7 client: BlobClient,
8 ?content_type: BlobContentType,
9 ?content_encoding: BlobContentEncoding,
10 ?content_language: BlobContentLanguage,
11 ?content_disposition: BlobContentDisposition,
12 ?metadata: Metadata,
13 ?tags: Tags,
14 ?if_modified_since: IfModifiedSinceCondition,
15 ?if_match: IfMatchCondition,
16 ?lease_id: LeaseId
17}
18
19impl PutAppendBlobBuilder {
20 pub fn into_future(mut self) -> PutAppendBlob {
21 Box::pin(async move {
22 let url = self.client.url()?;
23
24 let mut headers = Headers::new();
25 headers.insert(BLOB_TYPE, "AppendBlob");
26 headers.add(self.content_type);
27 headers.add(self.content_encoding);
28 headers.add(self.content_language);
29 headers.add(self.content_disposition);
30 headers.add(self.tags);
31 if let Some(metadata) = &self.metadata {
32 for m in metadata.iter() {
33 headers.add(m);
34 }
35 }
36 headers.add(self.if_modified_since);
37 headers.add(self.if_match);
38 headers.add(self.lease_id);
39
40 let mut request =
41 BlobClient::finalize_request(url, azure_core::Method::Put, headers, None)?;
42
43 let response = self.client.send(&mut self.context, &mut request).await?;
44 PutBlobResponse::from_headers(response.headers())
45 })
46 }
47}
48
49type PutAppendBlobResponse = PutBlobResponse;
50
51#[derive(Debug, Clone)]
52pub struct PutBlobResponse {
53 pub etag: String,
54 pub last_modified: OffsetDateTime,
55 pub request_id: RequestId,
56 pub date: OffsetDateTime,
57 pub request_server_encrypted: bool,
58}
59
60impl PutBlobResponse {
61 pub fn from_headers(headers: &Headers) -> azure_core::Result<PutBlobResponse> {
62 let etag = etag_from_headers(headers)?;
63 let last_modified = last_modified_from_headers(headers)?;
64 let request_id = request_id_from_headers(headers)?;
65 let date = date_from_headers(headers)?;
66 let request_server_encrypted = request_server_encrypted_from_headers(headers)?;
67
68 Ok(PutBlobResponse {
69 etag,
70 last_modified,
71 request_id,
72 date,
73 request_server_encrypted,
74 })
75 }
76}