@@ -16,6 +16,7 @@ pub struct BlobStoreS3 {
16
16
aws_sdk_s3:: Client ,
17
17
std:: pin:: Pin < Box < dyn std:: future:: Future < Output = aws_sdk_s3:: Client > + Send > > ,
18
18
> ,
19
+ container_name : Option < String > ,
19
20
}
20
21
21
22
/// AWS S3 runtime config literal options for authentication
@@ -69,6 +70,7 @@ impl BlobStoreS3 {
69
70
pub fn new (
70
71
region : String ,
71
72
auth_options : BlobStoreS3AuthOptions ,
73
+ container_name : Option < String > ,
72
74
) -> Result < Self > {
73
75
let builder = match & auth_options {
74
76
BlobStoreS3AuthOptions :: RuntimeConfigValues ( config) =>
@@ -95,17 +97,19 @@ impl BlobStoreS3 {
95
97
aws_sdk_s3:: Client :: new ( & sdk_config)
96
98
} ) ;
97
99
98
- Ok ( Self { builder, client : async_once_cell:: Lazy :: from_future ( client_fut) } )
100
+ Ok ( Self { builder, client : async_once_cell:: Lazy :: from_future ( client_fut) , container_name } )
99
101
}
100
102
}
101
103
102
104
#[ async_trait]
103
105
impl ContainerManager for BlobStoreS3 {
104
106
async fn get ( & self , name : & str ) -> Result < Arc < dyn Container > , Error > {
105
- let store = self . builder . clone ( ) . with_bucket_name ( name) . build ( ) . map_err ( |e| e. to_string ( ) ) ?;
107
+ let name = self . container_name . clone ( ) . unwrap_or_else ( || name. to_owned ( ) ) ;
108
+
109
+ let store = self . builder . clone ( ) . with_bucket_name ( & name) . build ( ) . map_err ( |e| e. to_string ( ) ) ?;
106
110
107
111
Ok ( Arc :: new ( S3Container {
108
- name : name . to_owned ( ) ,
112
+ name,
109
113
store,
110
114
client : self . client . get_unpin ( ) . await . clone ( ) ,
111
115
} ) )
0 commit comments