Class SessionTempFiles

java.lang.Object
vaadinx.SessionTempFiles

public final class SessionTempFiles extends Object
Per-VaadinSession scratch space for files that cross the browser boundary — the upload-to-temp-File (LOAD) and File-to-download (SAVE) staging that vaadinx.awt.FileDialog and vaadinx.swing.JFileChooser use to bridge the java.io.File semantic gap.

A browser-side Upload has no real file the server can see, so its bytes are written into a session-private temp directory and handed back to migrated code as an ordinary java.io.File (so new FileInputStream(f) / f.length() / f.getName() work unchanged). The whole directory tree is recursively deleted when the session is destroyed, so temp files don't outlive the user — registered lazily and exactly once per session via a self-removing SessionDestroyListener.

Work in progress alongside FileDialog / JFileChooser — see those classes' headers for the slice's status ledger.

  • Method Details

    • sessionDir

      public static Path sessionDir()
      The session-private temp root, created and registered for cleanup on first use. Throws IllegalStateException if there is no current session — file staging only happens on a UI/request thread.
    • newTransferDir

      public static Path newTransferDir()
      A fresh empty sub-directory under sessionDir() for one file-dialog show — either direction: LOAD stages uploaded bytes here, SAVE points the app's write target here. Per-show isolation keeps a later dialog from clobbering temp files an earlier one handed to the app (which may still hold the File reference / download link).