spring-cloud-aws icon indicating copy to clipboard operation
spring-cloud-aws copied to clipboard

Feature Request: Add S3Template upload ability of InputStream and content length

Open apetrelli opened this issue 1 year ago • 4 comments

Type: Feature

I notice that, for a simple upload of an InputStream, an entire S3Resource has to be created along with the S3OutputStream. This results in putting all the data or in memory or to disk

It would be nice to have, in S3Operations and S3Template, an upload method that has the following signature:

S3Resource upload(String bucketName, String key, InputStream inputStream, long contentLength)

This should call S3Client.putObject with RequestBody.fromInputStream, that uses the input stream and the content length so not to read the file twice, or dump in memory or on file.

apetrelli avatar Oct 24 '23 08:10 apetrelli

The S3OutputStream implementations we provide don't store complete file in memory or on disk, see InMemoryBufferingS3OutputStream.

I understand the reasoning but we would have to make it very clear that this particular method does not use the S3OutputStream but goes directly to SDK.

maciejwalkowiak avatar Oct 24 '23 13:10 maciejwalkowiak

@maciejwalkowiak another name is perfect for me as long as it works :-)

apetrelli avatar Oct 24 '23 15:10 apetrelli

Thinking about it, in fact what I wanted is something that uploads the InputStream without hitting the filesystem or putting everything in memory when the file is huge, so I guess that InMemoryBufferingS3OutputStream is perfect. I leave this issue open though, because it might be interesting for someone else.

apetrelli avatar Oct 24 '23 16:10 apetrelli