Skip to content

Commit

Permalink
Parse CompleteMultipartUploadResult (#4965)
Browse files Browse the repository at this point in the history
  • Loading branch information
tustvold committed Oct 21, 2023
1 parent 9f961f4 commit 0ad00d5
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions object_store/src/aws/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ pub(crate) enum Error {
#[snafu(display("Error performing complete multipart request: {}", source))]
CompleteMultipartRequest { source: crate::client::retry::Error },

#[snafu(display("Error getting complete multipart response body: {}", source))]
CompleteMultipartResponseBody { source: reqwest::Error },

#[snafu(display("Got invalid list response: {}", source))]
InvalidListResponse { source: quick_xml::de::DeError },

Expand Down Expand Up @@ -164,6 +167,13 @@ struct MultipartPart {
part_number: usize,
}

#[derive(Debug, Deserialize)]
#[serde(rename_all = "PascalCase", rename = "CompleteMultipartUploadResult")]
struct CompleteMultipartResult {
#[serde(rename = "ETag")]
e_tag: String,
}

#[derive(Deserialize)]
#[serde(rename_all = "PascalCase", rename = "DeleteResult")]
struct BatchDeleteResponse {
Expand Down Expand Up @@ -565,9 +575,17 @@ impl S3Client {
.await
.context(CompleteMultipartRequestSnafu)?;

let etag = get_etag(response.headers()).context(MetadataSnafu)?;
let data = response
.bytes()
.await
.context(CompleteMultipartResponseBodySnafu)?;

Ok(PutResult { e_tag: Some(etag) })
let response: CompleteMultipartResult =
quick_xml::de::from_reader(data.reader()).context(InvalidMultipartResponseSnafu)?;

Ok(PutResult {
e_tag: Some(response.e_tag),
})
}
}

Expand Down

0 comments on commit 0ad00d5

Please sign in to comment.