This is an automated email from the ASF dual-hosted git repository.
kylebarron pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-rs-object-store.git
The following commit(s) were added to refs/heads/main by this push:
new 233b23a Add `impl<T: Signed> Signed for PrefixStore<T>` (#739)
233b23a is described below
commit 233b23aeb6cdf16c4e89f4018d49f10b907825a1
Author: Thomas Tanon <[email protected]>
AuthorDate: Tue Jun 9 22:52:15 2026 +0200
Add `impl<T: Signed> Signed for PrefixStore<T>` (#739)
Small convenience feature
---
src/prefix.rs | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 74 insertions(+)
diff --git a/src/prefix.rs b/src/prefix.rs
index b6e9137..46cd681 100644
--- a/src/prefix.rs
+++ b/src/prefix.rs
@@ -22,6 +22,8 @@ use std::ops::Range;
use crate::multipart::{MultipartStore, PartId};
use crate::path::Path;
+#[cfg(feature = "cloud")]
+use crate::signer::Signer;
use crate::{
CopyOptions, GetOptions, GetResult, ListResult, MultipartId,
MultipartUpload, ObjectMeta,
ObjectStore, PutMultipartOptions, PutOptions, PutPayload, PutResult,
RenameOptions, Result,
@@ -234,6 +236,36 @@ impl<T: MultipartStore> MultipartStore for PrefixStore<T> {
}
}
+#[cfg(feature = "cloud")]
+#[async_trait::async_trait]
+impl<T: Signer> Signer for PrefixStore<T> {
+ async fn signed_url(
+ &self,
+ method: http::Method,
+ path: &Path,
+ expires_in: std::time::Duration,
+ ) -> Result<url::Url> {
+ self.inner
+ .signed_url(method, &self.full_path(path), expires_in)
+ .await
+ }
+
+ async fn signed_urls(
+ &self,
+ method: http::Method,
+ paths: &[Path],
+ expires_in: std::time::Duration,
+ ) -> Result<Vec<url::Url>> {
+ self.inner
+ .signed_urls(
+ method,
+ &paths.iter().map(|p| self.full_path(p)).collect::<Vec<_>>(),
+ expires_in,
+ )
+ .await
+ }
+}
+
#[cfg(not(target_arch = "wasm32"))]
#[cfg(test)]
mod tests {
@@ -363,4 +395,46 @@ mod tests {
multipart_out_of_order(&store).await;
multipart_race_condition(&store, true).await;
}
+
+ #[cfg(feature = "cloud")]
+ #[tokio::test]
+ async fn signer() {
+ #[derive(Debug)]
+ struct Foo;
+
+ #[async_trait::async_trait]
+ impl Signer for Foo {
+ async fn signed_url(
+ &self,
+ method: http::Method,
+ path: &Path,
+ _expires_in: std::time::Duration,
+ ) -> Result<url::Url> {
+
Ok(url::Url::parse(&format!("ex:{path}?method={method}")).unwrap())
+ }
+ }
+
+ assert_eq!(
+ PrefixStore::new(Foo, "prefix")
+ .signed_url(
+ http::Method::GET,
+ &"foo".into(),
+ std::time::Duration::from_secs(1)
+ )
+ .await
+ .unwrap(),
+ url::Url::parse("ex:prefix/foo?method=GET").unwrap()
+ );
+ assert_eq!(
+ PrefixStore::new(Foo, "prefix")
+ .signed_urls(
+ http::Method::GET,
+ &["foo".into()],
+ std::time::Duration::from_secs(1)
+ )
+ .await
+ .unwrap(),
+ vec![url::Url::parse("ex:prefix/foo?method=GET").unwrap()]
+ );
+ }
}