com.markosindustries.distroboy.aws.s3.UploadFromDiskToS3 Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aws-s3 Show documentation
Show all versions of aws-s3 Show documentation
DistroBoy support library for interacting with AWS S3 using the AWS SDK
The newest version!
package com.markosindustries.distroboy.aws.s3;
import com.markosindustries.distroboy.core.operations.ForEachOp;
import java.nio.file.Path;
import java.util.function.Function;
import software.amazon.awssdk.services.s3.S3Client;
public class UploadFromDiskToS3 implements ForEachOp {
private final S3Client s3Client;
private final String bucket;
private final Function keyAccessor;
private final Function pathAccessor;
public UploadFromDiskToS3(
S3Client s3Client,
String bucket,
Function keyAccessor,
Function pathAccessor) {
this.s3Client = s3Client;
this.bucket = bucket;
this.keyAccessor = keyAccessor;
this.pathAccessor = pathAccessor;
}
@Override
public void forEach(I input) {
String key = keyAccessor.apply(input);
Path path = pathAccessor.apply(input);
s3Client.putObject(req -> req.bucket(bucket).key(key), path);
}
}