andrebsguedes commented on code in PR #5681:
URL: https://github.com/apache/arrow-rs/pull/5681#discussion_r1695840718
##########
object_store/src/azure/client.rs:
##########
@@ -367,6 +546,112 @@ impl AzureClient {
Ok(())
}
+ pub async fn bulk_delete_request(&self, paths: Vec<Path>) ->
Result<Vec<Result<Path>>> {
+ if paths.is_empty() {
+ return Ok(Vec::new());
+ }
+
+ let credential = self.get_credential().await?;
+
+ let boundary = format!("batch_{}", uuid::Uuid::new_v4());
+
+ let mut body_bytes = Vec::with_capacity(paths.len() * 256);
+
+ for (idx, path) in paths.iter().enumerate() {
+ let url = self.config.path_url(path);
+
+ // Build subrequest with proper authorization
+ let request = self
+ .client
+ .request(Method::DELETE, url)
+ .header(CONTENT_LENGTH, HeaderValue::from(0))
+ .with_azure_authorization(&credential, &self.config.account)
+ .build()
+ .unwrap();
+
+ // Url for part requests must be relative and without base
+ let relative_url =
self.config.service.make_relative(request.url()).unwrap();
+
+ serialize_part_request(&mut body_bytes, &boundary, idx, request,
relative_url)
+ }
+
+ // Encode end marker
+ extend(&mut body_bytes, b"--");
+ extend(&mut body_bytes, boundary.as_bytes());
+ extend(&mut body_bytes, b"--");
+ extend(&mut body_bytes, b"\r\n");
+
+ // Send multipart request
+ let url = self.config.path_url(&Path::from("/"));
+ let batch_response = self
+ .client
+ .request(Method::POST, url)
+ .query(&[("restype", "container"), ("comp", "batch")])
+ .header(
+ CONTENT_TYPE,
+ HeaderValue::from_str(format!("multipart/mixed; boundary={}",
boundary).as_str())
+ .unwrap(),
+ )
+ .header(CONTENT_LENGTH, HeaderValue::from(body_bytes.len()))
+ .body(body_bytes)
+ .with_azure_authorization(&credential, &self.config.account)
Review Comment:
Yes, Azure expects each individual subrequest to be authorized separately, I
added a clarifying comment
--
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]