spring-cloud-aws
spring-cloud-aws copied to clipboard
Create a S3Resource for upload in a more concise way
Type: Feature
Is your feature request related to a problem? Please describe.
I'm trying to create an excel file and upload it to S3. I'm using fastexcel and it requires an OutputStream
to create a Workbook
which is the representation of an excel file. What I'm doing looks like..
S3Resource s3Resource = new S3Resource(bucket, key, s3Client, s3OutputStreamProvider);
try (Workbook workbook = new Workbook(s3Resource.getOutputStream(), "name", "version")) {
..
}
For this to happen I have to autowire S3Client
and S3OutputStreamProvider
and pass them to the constructor as above, which I find a little verbose when I'm happy with using the default ones.
I checked S3Template.upload()
but it requires an InputStream
and I couldn't find a way to utilize it in this case.
Describe the solution you'd like
Since S3Template
already has S3Client
and S3OutputStreamProvider
, something like S3Resource s3Resource = s3Template.createResource(bucket, key)
would be very convenient and easy to read.