@@ -160,7 +160,7 @@ impl Format {
160160 RealizedHref :: Url ( url) => {
161161 use object_store:: ObjectStore ;
162162
163- let ( object_store, path) = object_store :: parse_url_opts ( & url, options) ?;
163+ let ( object_store, path) = parse_url_opts ( & url, options) ?;
164164 let get_result = object_store. get ( & path) . await ?;
165165 let mut value: T = self . from_bytes ( get_result. bytes ( ) . await ?) ?;
166166 * value. self_href_mut ( ) = Some ( Href :: Url ( url) ) ;
@@ -241,7 +241,7 @@ impl Format {
241241 if let Ok ( url) = url:: Url :: parse ( & href) {
242242 use object_store:: ObjectStore ;
243243
244- let ( object_store, path) = object_store :: parse_url_opts ( & url, options) ?;
244+ let ( object_store, path) = parse_url_opts ( & url, options) ?;
245245 let bytes = self . into_vec ( value) ?;
246246 let put_result = object_store. put ( & path, bytes. into ( ) ) . await ?;
247247 Ok ( Some ( put_result) )
@@ -267,6 +267,33 @@ impl Format {
267267 }
268268}
269269
270+ #[ cfg( feature = "object-store" ) ]
271+ fn parse_url_opts < I , K , V > (
272+ url : & url:: Url ,
273+ options : I ,
274+ ) -> Result < ( Box < dyn object_store:: ObjectStore > , object_store:: path:: Path ) >
275+ where
276+ I : IntoIterator < Item = ( K , V ) > ,
277+ K : AsRef < str > ,
278+ V : Into < String > ,
279+ {
280+ use object_store:: ObjectStoreScheme ;
281+
282+ // It's technically inefficient to parse it twice, but we're doing this to
283+ // then do IO so who cares.
284+ #[ cfg( feature = "object-store-aws" ) ]
285+ if let Ok ( ( ObjectStoreScheme :: AmazonS3 , path) ) = ObjectStoreScheme :: parse ( url) {
286+ let mut builder = object_store:: aws:: AmazonS3Builder :: from_env ( ) ;
287+ for ( key, value) in options {
288+ builder = builder. with_config ( key. as_ref ( ) . parse ( ) ?, value) ;
289+ }
290+ return Ok ( ( Box :: new ( builder. with_url ( url. to_string ( ) ) . build ( ) ?) , path) ) ;
291+ }
292+
293+ let result = object_store:: parse_url_opts ( url, options) ?;
294+ Ok ( result)
295+ }
296+
270297impl Default for Format {
271298 fn default ( ) -> Self {
272299 Self :: Json ( false )
0 commit comments