Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

Uploading files directly to Amazon s3 without Using temp location

Srikanth Shanigaram
8 years ago Dec 29, 2014 5:30am
Thomas Mattsson
8 years ago Dec 29, 2014 8:06am
Srikanth Shanigaram
8 years ago Dec 29, 2014 11:13am
Thomas Mattsson
8 years ago Dec 29, 2014 12:05pm
Srikanth Shanigaram
8 years ago Jan 05, 2015 12:55pm
omkar darekar
7 years ago Sep 04, 2015 7:41am

Thomas Mattsson: 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.

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;