-
-
Notifications
You must be signed in to change notification settings - Fork 294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In-Memory Buffered S3 OutputStream #392
Comments
Agreed that it would be nice to have. The benefit of storing first on disk is that in case of an upload failure, uploading part can be retried as it's possible to rewind the input stream. At this stage, for v3 we will recommend using https://github.com/CI-CMG/aws-s3-outputstream and adding a custom We are also waiting for AWS to implement: aws/aws-sdk-java-v2#3128 Also, if you have an input stream you can fall back to using plain AWS SDK which offers uploading data from it. |
@maciejwalkowiak I have an implementation of this which is thread-safe with ReentrantLock that I can contribute if that would be helpful. In terms of retry, I’m not sure why it would be an issue If a part fails you can retry it without failing the entire upload. If we buffer and copy to a byte array, we can even parallelize the multipart upload, and retry with a backoff mechanism. |
@sgarfinkel create a PR please and lets see! |
Fixes #392 Co-authored-by: Maciej Walkowiak <walkowiak.maciej@yahoo.com>
Type: Feature
Is your feature request related to a problem? Please describe.
The
S3Resource
in the old spring-cloud-aws used to return an OutputStream that would buffer the content, and send the content (when it exceeded the buffer capacity), to S3 as a multipart upload. This is particularly useful for large streaming files where the user may not want to store the entire file on the filesystem. The current OutputStream(s) all write the content to an intermediate file on disk before sending it to S3.Describe the solution you'd like
Implement an
InMemoryBufferedS3OutputStream
which uses a ByteBuffer to store written bytes. Flush the buffer (starting a multipart upload, if not yet started) and send the content of the buffer as each chunk of the multipart upload. Complete the multipart upload whenclose
is called.Describe alternatives you've considered
There isn't really one in the current implementation. If
AbstractTempFileS3OutputStream
usedPath
instead ofFile
, there might be a way to do it with a custom filesystem implementation.The text was updated successfully, but these errors were encountered: