Uploading files directly to Amazon s3 without Using temp location

HI all,
I am uploading files to temp folder and from temp to amazon s3 bucket using vaadin. But in case of large files(1gb ) i am getting Communication error message. What is happening in my application i am unable to understand.
Please guide me to solve this one.

To be clear; what parts are Vaadin in this? Are you uploading to a Vaadin app, storing the file, and then using Java code to transfer the file directly to S3?

Gigabyte files are very complicated to handle correctly, and using them through Vaadin might indeed prove challenging. If the transfer itself takes more time than the session timout (default is 30 minutes), you vaadin app might time out during the transfer. An easy way to test this is to change the timeout to something like 60 minutes (or however long it takes to upload the file), but a better way is to find a way how to handle the file some other way.

You’ll have the same timeout issue on any Servlet on the server, Vaadin or not. But if you create your own custom servlet for receiving the file, you have better control over it’s configuration (and it won’t lock the Vaadin session). Of course, you will need some custom client-side code as well, so that your upload component contacts the other servlet instead of the default one. I don’t have any sample code for that unfortunately (never tried it, in fact), but you’ll probably find some online somewhere.

Thank you for your reply.
Actually in my project i need to store videos in Amazon Web Service buckets using vaadin 6.8 as portlet in Liferay.
So first i am uploading video file to a temp location in my server it is working fine then after i am transferring this file from temp location to s3 bucket using the AWS java sdk jars. In AWS , TransferManger class will do the transfer process while doing, this class blocks or place the all other threads in Queue till transfer Completes and it wont allow a component to display while this class work is going on for example: i used indicator to see the progress but unfortunatly indicator is not showing
I thought that these things are happening in vaadin because of Transfer Manager class of aws.

And also i tried to set vaadin session time out to -1 means it never expires but some online forums says that it leads to memeory leakage and out of memory errors

I see. Try moving the S3 upload to a background thread, with e.g. a Thread Pool Executor. This way the upload won’t block Vaadin operations.

Thank you alot
I solved issue.


Hi Thomas,

please find my below code,

Here path = “G:/”; is set by be manually as i know the file is stored in that drive, but what if user from his pc want to upload the file.

How to set the path dynamically.

Or different code or procedure???

import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;

import com.vaadin.server.Page;
import com.vaadin.ui.Notification;
import com.vaadin.ui.Upload.Receiver;

public class ImageUploader implements Receiver{

private File file;

public OutputStream receiveUpload(String filename, String mimeType) {

    FileOutputStream fos = null;
    String path = "G:/";    
    file = new File(path + filename);
    AmazonS3Example AWSS3 = new AmazonS3Example();
    try {
        fos = new FileOutputStream(file);
    } catch (final java.io.FileNotFoundException e) {
        new Notification("Could not open file<br/>",e.getMessage(),Notification.Type.ERROR_MESSAGE).show(Page.getCurrent());
        return null;
    return fos;