4848import org .janelia .saalfeldlab .n5 .zarr .ZarrKeyValueWriter ;
4949import org .janelia .saalfeldlab .n5 .zarr .v3 .ZarrV3KeyValueReader ;
5050import org .janelia .saalfeldlab .n5 .zarr .v3 .ZarrV3KeyValueWriter ;
51- import software .amazon .awssdk .auth .credentials .AwsCredentials ;
52- import software .amazon .awssdk .auth .credentials .DefaultCredentialsProvider ;
53- import software .amazon .awssdk .http .SdkHttpClient ;
5451import software .amazon .awssdk .services .s3 .S3Client ;
52+ import software .amazon .awssdk .services .s3 .S3ClientBuilder ;
5553
5654import javax .annotation .Nullable ;
5755import java .io .Serializable ;
6058import java .nio .file .Paths ;
6159import java .util .Arrays ;
6260import java .util .function .BiFunction ;
61+ import java .util .function .Consumer ;
6362import java .util .regex .Pattern ;
6463
6564import static org .janelia .saalfeldlab .n5 .universe .StorageFormat .getStorageFromNestedScheme ;
@@ -91,11 +90,7 @@ public class N5Factory implements Serializable {
9190 private boolean zarrMergeAttributes = true ;
9291 private String googleCloudProjectId = null ;
9392 private boolean googleCloudCreateBucket = false ;
94- private String s3Region = null ;
95- private AwsCredentials s3Credentials = null ;
96- private SdkHttpClient .Builder <?> s3ClientBuilder = null ;
97- private boolean s3Anonymous = true ;
98- private String s3Endpoint ;
93+ private Consumer <S3ClientBuilder > builderConfig ;
9994 private StorageFormat preferredStorageFormat = null ;
10095
10196 public N5Factory hdf5DefaultBlockSize (final int ... blockSize ) {
@@ -152,30 +147,6 @@ public N5Factory googleCloudProjectId(final String projectId) {
152147 return this ;
153148 }
154149
155- /**
156- * This factory will use the {@link DefaultCredentialsProvider} to
157- * find s3 credentials.
158- *
159- * @return this N5Factory
160- */
161- public N5Factory s3UseCredentials () {
162-
163- s3Anonymous = false ;
164- return this ;
165- }
166-
167- public N5Factory s3UseCredentials (final AwsCredentials credentials ) {
168-
169- this .s3Credentials = credentials ;
170- return this ;
171- }
172-
173- public N5Factory s3ClientConfiguration (final SdkHttpClient .Builder <?> clientBuilder ) {
174-
175- this .s3ClientBuilder = clientBuilder ;
176- return this ;
177- }
178-
179150 /**
180151 * When N5Factory cannot determine the StorageFormat from the URI, it will attempt to
181152 * try and create a reader/writer with all known StorageFormat values.
@@ -191,28 +162,22 @@ public N5Factory preferredStorageFormat(final StorageFormat format) {
191162 return this ;
192163 }
193164
194- @ Deprecated
195- public N5Factory s3RetryWithCredentials () {
196-
197- return this ;
198- }
199-
200- public N5Factory s3Endpoint (final String s3Endpoint ) {
201-
202- this .s3Endpoint = s3Endpoint ;
203- return this ;
204- }
205-
206- public N5Factory s3Region (final String s3Region ) {
165+ /**
166+ * This factory will use the builderConfig to configure the {@link S3ClientBuilder},
167+ * and thereby the {@link S3Client}.
168+ *
169+ * @return this N5Factory
170+ */
171+ public N5Factory s3Configuration (final Consumer <S3ClientBuilder > builderConfig ) {
207172
208- this .s3Region = s3Region ;
173+ this .builderConfig = builderConfig ;
209174 return this ;
210175 }
211176
212177 protected S3Client createS3 (final String uri ) {
213178
214179 try {
215- return AmazonS3Utils .createS3 (uri , s3Endpoint , AmazonS3Utils . getS3Credentials ( s3Credentials , s3Anonymous ), s3ClientBuilder , s3Region );
180+ return AmazonS3Utils .createS3 (uri , builderConfig );
216181 } catch (final Throwable e ) {
217182 throw new N5Exception ("Could not create s3 client from uri: " + uri , e );
218183 }
0 commit comments