Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


Code Block
// For later usage, e.g. in a message displayed by uploadSucceeded-Event
File file;

// Build receiver
Receiver receiver = new Receiver() {

	public OutputStream receiveUpload(final String filename, final String mimeType) {
        // Create upload stream to write to

        FileOutputStream fos = null;
        try {

        	// Get path to servlet's temp directory
        	final File temporaryDirectory = (File) VaadinServlet.getCurrent().getServletContext().getAttribute(ServletContext.TEMPDIR);

            // Concatenate temporaryDirectory with filename and open the file for writing.
            file = new File(temporaryDirectory, filename);

        	// Create the output stream
            fos = new FileOutputStream(file);

        } catch (final e) {
  "Could not open file", Type.ERROR_MESSAGE);
            return null;
        return fos;

// Set Receiver for upload component