-
Notifications
You must be signed in to change notification settings - Fork 11
/
OcflS3Client.java
686 lines (603 loc) · 24.1 KB
/
OcflS3Client.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
/*
* The MIT License (MIT)
*
* Copyright (c) 2019-2021 University of Wisconsin Board of Regents
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package io.ocfl.aws;
import io.ocfl.api.OcflRepository;
import io.ocfl.api.exception.OcflIOException;
import io.ocfl.api.util.Enforce;
import io.ocfl.core.storage.cloud.CloudClient;
import io.ocfl.core.storage.cloud.CloudObjectKey;
import io.ocfl.core.storage.cloud.HeadResult;
import io.ocfl.core.storage.cloud.KeyNotFoundException;
import io.ocfl.core.storage.cloud.ListResult;
import io.ocfl.core.util.UncheckedFiles;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.function.BiConsumer;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import software.amazon.awssdk.core.async.AsyncRequestBody;
import software.amazon.awssdk.core.async.AsyncResponseTransformer;
import software.amazon.awssdk.services.s3.S3AsyncClient;
import software.amazon.awssdk.services.s3.model.DeleteObjectsRequest;
import software.amazon.awssdk.services.s3.model.GetObjectRequest;
import software.amazon.awssdk.services.s3.model.HeadBucketRequest;
import software.amazon.awssdk.services.s3.model.HeadObjectRequest;
import software.amazon.awssdk.services.s3.model.ListObjectsV2Request;
import software.amazon.awssdk.services.s3.model.ListObjectsV2Response;
import software.amazon.awssdk.services.s3.model.NoSuchBucketException;
import software.amazon.awssdk.services.s3.model.NoSuchKeyException;
import software.amazon.awssdk.services.s3.model.ObjectIdentifier;
import software.amazon.awssdk.services.s3.model.PutObjectRequest;
import software.amazon.awssdk.services.s3.model.S3Exception;
import software.amazon.awssdk.transfer.s3.S3TransferManager;
/**
* CloudClient implementation that uses Amazon's S3 synchronous v2 client
*/
public class OcflS3Client implements CloudClient {
private static final Logger LOG = LoggerFactory.getLogger(OcflS3Client.class);
private static final long EIGHT_MB = 8 * 1024 * 1024;
private final S3AsyncClient s3Client;
private final S3TransferManager transferManager;
private final String bucket;
private final String repoPrefix;
private final CloudObjectKey.Builder keyBuilder;
private final BiConsumer<String, PutObjectRequest.Builder> putObjectModifier;
/**
* Used to create a new OcflS3Client instance.
*
* @return builder
*/
public static Builder builder() {
return new Builder();
}
/**
* @see OcflS3Client#builder()
*
* @param s3Client aws sdk s3 client
* @param bucket s3 bucket
*/
public OcflS3Client(S3AsyncClient s3Client, String bucket) {
this(s3Client, bucket, null, null, null);
}
/**
* @see OcflS3Client#builder()
*
* @param s3Client aws sdk s3 client, not null
* @param bucket s3 bucket, not null
* @param prefix key prefix, may be null
* @param transferManager aws sdk s3 transfer manager, not null
* @param putObjectModifier hook for modifying putObject requests, may be null
*/
public OcflS3Client(
S3AsyncClient s3Client,
String bucket,
String prefix,
S3TransferManager transferManager,
BiConsumer<String, PutObjectRequest.Builder> putObjectModifier) {
this.s3Client = Enforce.notNull(s3Client, "s3Client cannot be null");
this.bucket = Enforce.notBlank(bucket, "bucket cannot be blank");
this.repoPrefix = sanitizeRepoPrefix(prefix == null ? "" : prefix);
this.transferManager = Enforce.notNull(transferManager, "transferManager cannot be null");
this.keyBuilder = CloudObjectKey.builder().prefix(repoPrefix);
this.putObjectModifier = putObjectModifier != null ? putObjectModifier : (k, b) -> {};
}
private static String sanitizeRepoPrefix(String repoPrefix) {
return repoPrefix.substring(0, indexLastNonSlash(repoPrefix));
}
private static int indexLastNonSlash(String string) {
for (int i = string.length(); i > 0; i--) {
if (string.charAt(i - 1) != '/') {
return i;
}
}
return 0;
}
/**
* Nothing to do
*/
@Override
public void close() {
// noop
}
/**
* {@inheritDoc}
*/
@Override
public String bucket() {
return bucket;
}
/**
* {@inheritDoc}
*/
@Override
public String prefix() {
return repoPrefix;
}
/**
* {@inheritDoc}
*/
@Override
public Future<CloudObjectKey> uploadFileAsync(Path srcPath, String dstPath) {
return uploadFileAsync(srcPath, dstPath, null);
}
/**
* {@inheritDoc}
*/
@Override
public Future<CloudObjectKey> uploadFileAsync(Path srcPath, String dstPath, String contentType) {
var fileSize = UncheckedFiles.size(srcPath);
var dstKey = keyBuilder.buildFromPath(dstPath);
LOG.debug("Uploading {} to bucket {} key {} size {}", srcPath, bucket, dstKey, fileSize);
var builder = PutObjectRequest.builder().contentType(contentType);
putObjectModifier.accept(dstKey.getKey(), builder);
if (fileSize >= EIGHT_MB) {
var upload = transferManager.uploadFile(req -> req.source(srcPath)
.putObjectRequest(
builder.bucket(bucket).key(dstKey.getKey()).build())
.build());
return new UploadFuture(upload.completionFuture(), srcPath, dstKey);
} else {
var upload = s3Client.putObject(
builder.bucket(bucket).key(dstKey.getKey()).build(), srcPath);
return new UploadFuture(upload, srcPath, dstKey);
}
}
/**
* {@inheritDoc}
*/
@Override
public CloudObjectKey uploadFile(Path srcPath, String dstPath) {
return uploadFile(srcPath, dstPath, null);
}
/**
* {@inheritDoc}
*/
@Override
public CloudObjectKey uploadFile(Path srcPath, String dstPath, String contentType) {
var future = uploadFileAsync(srcPath, dstPath, contentType);
try {
return future.get();
} catch (ExecutionException e) {
throw (RuntimeException) e.getCause();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new OcflS3Exception("Failed ot upload " + srcPath, e);
}
}
/**
* {@inheritDoc}
*/
@Override
public CloudObjectKey uploadBytes(String dstPath, byte[] bytes, String contentType) {
var dstKey = keyBuilder.buildFromPath(dstPath);
LOG.debug("Writing bytes to bucket {} key {}", bucket, dstKey);
var builder = PutObjectRequest.builder().contentType(contentType);
putObjectModifier.accept(dstKey.getKey(), builder);
try {
s3Client.putObject(builder.bucket(bucket).key(dstKey.getKey()).build(), AsyncRequestBody.fromBytes(bytes))
.join();
} catch (RuntimeException e) {
throw new OcflS3Exception("Failed to upload bytes to " + dstKey, OcflS3Util.unwrapCompletionEx(e));
}
return dstKey;
}
/**
* {@inheritDoc}
*/
@Override
public CloudObjectKey copyObject(String srcPath, String dstPath) {
var srcKey = keyBuilder.buildFromPath(srcPath);
var dstKey = keyBuilder.buildFromPath(dstPath);
LOG.debug("Copying {} to {} in bucket {}", srcKey, dstKey, bucket);
try {
var copy = s3Client.copyObject(req -> req.destinationBucket(bucket)
.destinationKey(dstKey.getKey())
.sourceBucket(bucket)
.sourceKey(srcKey.getKey())
.build());
copy.join();
} catch (RuntimeException e) {
var cause = OcflS3Util.unwrapCompletionEx(e);
if (wasNotFound(cause)) {
throw new KeyNotFoundException("Key " + srcKey + " not found in bucket " + bucket, cause);
}
throw new OcflS3Exception("Failed to copy object from " + srcKey + " to " + dstKey, cause);
}
return dstKey;
}
/**
* {@inheritDoc}
*/
@Override
public Path downloadFile(String srcPath, Path dstPath) {
var srcKey = keyBuilder.buildFromPath(srcPath);
LOG.debug("Downloading from bucket {} key {} to {}", bucket, srcKey, dstPath);
try {
transferManager
.downloadFile(req -> req.getObjectRequest(getReq ->
getReq.bucket(bucket).key(srcKey.getKey()).build())
.destination(dstPath)
.build())
.completionFuture()
.join();
} catch (RuntimeException e) {
var cause = OcflS3Util.unwrapCompletionEx(e);
if (wasNotFound(cause)) {
throw new KeyNotFoundException("Key " + srcKey + " not found in bucket " + bucket, cause);
}
throw new OcflS3Exception("Failed to download " + srcKey + " to " + dstPath, cause);
}
return dstPath;
}
/**
* {@inheritDoc}
*/
@Override
public InputStream downloadStream(String srcPath) {
var srcKey = keyBuilder.buildFromPath(srcPath);
LOG.debug("Streaming from bucket {} key {}", bucket, srcKey);
try {
return s3Client.getObject(
GetObjectRequest.builder()
.bucket(bucket)
.key(srcKey.getKey())
.build(),
AsyncResponseTransformer.toBlockingInputStream())
.join();
} catch (RuntimeException e) {
var cause = OcflS3Util.unwrapCompletionEx(e);
if (wasNotFound(cause)) {
throw new KeyNotFoundException("Key " + srcKey + " not found in bucket " + bucket, cause);
}
throw new OcflS3Exception("Failed to download " + srcKey, cause);
}
}
/**
* {@inheritDoc}
*/
@Override
public String downloadString(String srcPath) {
try (var stream = downloadStream(srcPath)) {
return new String(stream.readAllBytes(), StandardCharsets.UTF_8);
} catch (IOException e) {
throw new OcflIOException(e);
}
}
/**
* {@inheritDoc}
*/
@Override
public HeadResult head(String path) {
var key = keyBuilder.buildFromPath(path);
try {
var s3Result = s3Client.headObject(HeadObjectRequest.builder()
.bucket(bucket)
.key(key.getKey())
.build())
.join();
return new HeadResult()
.setContentEncoding(s3Result.contentEncoding())
.setContentLength(s3Result.contentLength())
.setETag(s3Result.eTag())
.setLastModified(s3Result.lastModified());
} catch (RuntimeException e) {
var cause = OcflS3Util.unwrapCompletionEx(e);
if (wasNotFound(cause)) {
throw new KeyNotFoundException("Key " + key + " not found in bucket " + bucket, cause);
}
throw new OcflS3Exception("Failed to HEAD " + key, cause);
}
}
/**
* {@inheritDoc}
*/
@Override
public ListResult list(String prefix) {
var prefixedPrefix = keyBuilder.buildFromPath(prefix);
return toListResult(ListObjectsV2Request.builder().bucket(bucket).prefix(prefixedPrefix.getKey()));
}
/**
* {@inheritDoc}
*/
@Override
public ListResult listDirectory(String path) {
var prefix = keyBuilder.buildFromPath(path).getKey();
if (!prefix.isEmpty() && !prefix.endsWith("/")) {
prefix = prefix + "/";
}
LOG.debug("Listing directory {} in bucket {}", prefix, bucket);
return toListResult(
ListObjectsV2Request.builder().bucket(bucket).delimiter("/").prefix(prefix));
}
/**
* {@inheritDoc}
*/
@Override
public boolean directoryExists(String path) {
var prefix = keyBuilder.buildFromPath(path).getKey();
if (!prefix.isEmpty() && !prefix.endsWith("/")) {
prefix = prefix + "/";
}
LOG.debug("Checking existence of {} in bucket {}", prefix, bucket);
try {
var response = s3Client.listObjectsV2(ListObjectsV2Request.builder()
.bucket(bucket)
.delimiter("/")
.prefix(prefix)
.maxKeys(1)
.build())
.join();
return response.contents().stream().findAny().isPresent()
|| response.commonPrefixes().stream().findAny().isPresent();
} catch (RuntimeException e) {
throw new OcflS3Exception("Failed to list objects under " + prefix, OcflS3Util.unwrapCompletionEx(e));
}
}
/**
* {@inheritDoc}
*/
@Override
public void deletePath(String path) {
LOG.debug("Deleting path {} in bucket {}", path, bucket);
var keys = list(path).getObjects().stream()
.map(ListResult.ObjectListing::getKey)
.collect(Collectors.toList());
deleteObjectsInternal(keys);
}
/**
* {@inheritDoc}
*/
@Override
public void deleteObjects(Collection<String> objectPaths) {
if (!objectPaths.isEmpty()) {
var objectKeys = objectPaths.stream()
.filter(Objects::nonNull)
.map(keyBuilder::buildFromPath)
.collect(Collectors.toList());
deleteObjectsInternal(objectKeys);
}
}
private void deleteObjectsInternal(Collection<CloudObjectKey> objectKeys) {
LOG.debug("Deleting objects in bucket {}: {}", bucket, objectKeys);
if (!objectKeys.isEmpty()) {
var objectIds = objectKeys.stream()
.map(key -> ObjectIdentifier.builder().key(key.getKey()).build())
.collect(Collectors.toList());
try {
var futures = new ArrayList<CompletableFuture<?>>();
// Can only delete at most 1,000 objects per request
for (int i = 0; i < objectIds.size(); i += 999) {
var toDelete = objectIds.subList(i, Math.min(objectIds.size(), i + 999));
futures.add(s3Client.deleteObjects(DeleteObjectsRequest.builder()
.bucket(bucket)
.delete(builder -> builder.objects(toDelete))
.build()));
}
CompletableFuture.allOf(futures.toArray(new CompletableFuture[] {}))
.join();
} catch (RuntimeException e) {
throw new OcflS3Exception("Failed to delete objects " + objectIds, OcflS3Util.unwrapCompletionEx(e));
}
}
}
/**
* {@inheritDoc}
*/
@Override
public void safeDeleteObjects(String... objectPaths) {
safeDeleteObjects(Arrays.asList(objectPaths));
}
/**
* {@inheritDoc}
*/
@Override
public void safeDeleteObjects(Collection<String> objectPaths) {
try {
deleteObjects(objectPaths);
} catch (RuntimeException e) {
LOG.error("Failed to cleanup objects in bucket {}: {}", bucket, objectPaths, e);
}
}
/**
* {@inheritDoc}
*/
@Override
public boolean bucketExists() {
try {
s3Client.headBucket(HeadBucketRequest.builder().bucket(bucket).build())
.join();
return true;
} catch (RuntimeException e) {
var cause = OcflS3Util.unwrapCompletionEx(e);
if (wasNotFound(cause)) {
return false;
}
throw new OcflS3Exception("Failed ot HEAD bucket " + bucket, cause);
}
}
private ListResult toListResult(ListObjectsV2Request.Builder requestBuilder) {
try {
var result = s3Client.listObjectsV2(requestBuilder.build()).join();
var prefixLength = prefixLength(result.prefix());
var repoPrefixLength = repoPrefix.isBlank() ? 0 : repoPrefix.length() + 1;
var objects = toObjectListings(result, prefixLength);
var dirs = toDirectoryListings(result, repoPrefixLength);
while (Boolean.TRUE.equals(result.isTruncated())) {
result = s3Client.listObjectsV2(requestBuilder
.continuationToken(result.nextContinuationToken())
.build())
.join();
objects.addAll(toObjectListings(result, prefixLength));
dirs.addAll(toDirectoryListings(result, repoPrefixLength));
}
return new ListResult().setObjects(objects).setDirectories(dirs);
} catch (RuntimeException e) {
throw new OcflS3Exception("Failed to list objects", OcflS3Util.unwrapCompletionEx(e));
}
}
private List<ListResult.ObjectListing> toObjectListings(ListObjectsV2Response result, int prefixLength) {
return result.contents().stream()
.map(o -> {
var key = o.key();
return new ListResult.ObjectListing()
.setKey(keyBuilder.buildFromKey(key))
.setKeySuffix(key.substring(prefixLength));
})
.collect(Collectors.toList());
}
private List<ListResult.DirectoryListing> toDirectoryListings(ListObjectsV2Response result, int repoPrefixLength) {
return result.commonPrefixes().stream()
.filter(p -> p.prefix() != null)
.map(p -> {
var path = p.prefix();
return new ListResult.DirectoryListing().setPath(path.substring(repoPrefixLength));
})
.collect(Collectors.toList());
}
private int prefixLength(String prefix) {
var prefixLength = 0;
if (prefix != null && !prefix.isEmpty()) {
prefixLength = prefix.length();
if (!prefix.endsWith("/")) {
prefixLength += 1;
}
}
return prefixLength;
}
/**
* Returns true if the exception indicates the object/bucket was NOT found in S3.
*
* @param e the exception
* @return true if the object/bucket was NOT found in S3.
*/
private boolean wasNotFound(Throwable e) {
if (e instanceof NoSuchKeyException || e instanceof NoSuchBucketException) {
return true;
} else if (e instanceof S3Exception) {
// It seems like the CRT client does not return NoSuchKeyExceptions...
var s3e = (S3Exception) e;
return 404 == s3e.statusCode();
}
return false;
}
public static class Builder {
private S3AsyncClient s3Client;
private S3TransferManager transferManager;
private String bucket;
private String repoPrefix;
private BiConsumer<String, PutObjectRequest.Builder> putObjectModifier;
/**
* The AWS SDK S3 client. Required.
* <p>
* This client should NOT be the same client that's used with the transfer manager, and it should NOT be
* the CRT client. The reason being that the CRT client only performs well when operating on files greater
* than 8MB, and is <i>significantly</i> slower when operating on smaller files.
* <p>
* This client is NOT closed when the repository is closed, and the user is responsible for closing it when appropriate.
*
* @param s3Client s3 client
* @return builder
*/
public Builder s3Client(S3AsyncClient s3Client) {
this.s3Client = Enforce.notNull(s3Client, "s3Client cannot be null");
return this;
}
/**
* The AWS SDK S3 transfer manager. Required.
* <p>
* The transfer manager should be configured per the official AWS documentation, using the CRT client.
* <p>
* If you are using a 3rd party S3 implementation, then you will likely additionally need to disable the
* <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/checking-object-integrity.html">object integrity check</a>
* as most 3rd party implementations do not support it. This easy to do on the CRT client builder by setting
* {@code checksumValidationEnabled()} to {@code false}.
* <p>
* The transfer manager will NOT be closed when the repository is closed, and the user is
* responsible for closing it when appropriate.
*
* @param transferManager S3 transfer manager
* @return builder
*/
public Builder transferManager(S3TransferManager transferManager) {
this.transferManager = Enforce.notNull(transferManager, "transferManager cannot be null");
return this;
}
/**
* The S3 bucket to use. Required.
*
* @param bucket s3 bucket
* @return builder
*/
public Builder bucket(String bucket) {
this.bucket = Enforce.notBlank(bucket, "bucket cannot be blank");
return this;
}
/**
* The key prefix to use for the repository. Optional.
*
* @param repoPrefix key prefix
* @return builder
*/
public Builder repoPrefix(String repoPrefix) {
this.repoPrefix = repoPrefix;
return this;
}
/**
* Provides a hook to modify putObject requests before they are executed. It is intended to be used to set
* object attributes such as tags.
*
* <p>The first argument is the object key the request is for, and the second is the request builder to apply
* changes to.
*
* @param putObjectModifier hook for modifying putObject requests
* @return builder
*/
public Builder putObjectModifier(BiConsumer<String, PutObjectRequest.Builder> putObjectModifier) {
this.putObjectModifier = putObjectModifier;
return this;
}
/**
* Constructs a new {@link OcflS3Client}. {@link #s3Client(S3AsyncClient)} and {@link #bucket(String)} must be set.
* <p>
* Remember to call {@link OcflRepository#close()} when you are done with the repository so that the default
* S3 transfer manager is closed.
*
* @return OcflS3Client
*/
public OcflS3Client build() {
return new OcflS3Client(s3Client, bucket, repoPrefix, transferManager, putObjectModifier);
}
}
}