Get FileInputStream when Upload starts

I would like to upload files to AWS S3 storage using Vaadin if possible.

I see that setting the Html5File.setStreamVariable… I can return an OutputStream using the StreamVariable.getOutputStream() BUT AWS S3 requires an InputStream instead of an OutputStream. I also saw I can convert an OutputStream to an InputStream but that seems a little crazy.

I’m thinking if I can somehow get the FileInputStream from Vaadin, then I can use that in Amazon’s Java SDK for S3 uploads.

AWS S3 TransferManager.Upload handles the InProgress, Failed, Completed etc info, the only thing missing is InputStream.

Anyway to access the Java InputStream once the file starts to upload using Vaadin?


The way the stream variable is constructed is that you give it an OutputStream where the data that is streamed from the browser is written. It is not written to any file automatically so there is no FileInputStream that you can access.

One way would be, like you said, to make a stream that acts as an OutputStream for Vaadin and forwards the data as an InputStream to S3. Of course you can also write the stream to a temp file first and then create a FileInputStream for that but it seems like a waste to go through a file.

Thanks, I was hoping there’s a way in the stream variable I can give it an InputStream instead of an OutputStream and all the data flows straight to S3. I’ll take a look at the conversion… I’ll also take a look at just using S3 REST API and figure a way to tie that into Vaadin’s UI.

Yea, saving files to the server and then in turn sending those files to S3 will seem to use excess resources.


Were you ever able to come up with a good solution for this? I’m facing the same issue in a project I’m currently working on. We are experiencing issues with really large files (500MB+) in which we’re getting session timeouts because the upload to a temp file on the server plus the push to S3 takes too long. If we could avoid the temporary file and intercept the input stream to directly push it to S3, this would avoid those issues.

I am working on uploadin files to Amazon s3.But in case of large files vaadin is giving session time out so i set session time to -1 using session-config in web.xml but it leads to memory leaks and some times i am getting communication error also when upload 1gb files.
And TransferManager class is not allowing vaadin components to show progress bar while uploading from temp to s3.
Can anyone guide to do solve these issues.
Thanks in advance