|Manuals

File Transfer and Drag and Drop

Thinfinity VirtualUI lets end users move files between their device and the application: files the application saves can be downloaded by the browser, files the user picks or drops in the browser are uploaded to the server, and the application can react to files dragged onto the session page.

Downloading Files to the User’s Device

When the application opens a Save dialog, VirtualUI virtualizes it: the file the application writes is sent to the browser as a download on the user’s device. See Save As for how the dialog renders.

The application can also send a file explicitly with the SDK’s DownloadFile method:

  • DownloadFile(LocalFilename) — sends the file, keeping its name.
  • DownloadFile(LocalFilename, RemoteFilename) — sends the file under a different name.
  • DownloadFile(LocalFilename, RemoteFilename, MimeType) — also sets the content type. When a MIME type is given, the browser handles the content (for example, it opens a PDF in a tab); leave it blank to force a download.

The OnDownloadEnd event notifies the application when the transfer completes.

Uploading Files to the Application

When the application opens an Open dialog, VirtualUI shows an upload dialog in the browser instead — “Please, select or drop a file:” — where the user picks a file from their device or drops one onto the dialog. The dialog honors the file-type filter and the multiple-selection setting of the application’s dialog. Once uploaded, the application receives the file as if the user had picked it locally. See Open File.

The application can also start an upload explicitly:

  • UploadFile(ServerDirectory) — prompts the user for a file and uploads it to the given server directory. Without a directory, the file goes to the VirtualUI public path — the Shared Files Folder.
  • UploadFileEx(ServerDirectory, out FileName) — same, and returns the full path of the uploaded file.

The OnUploadEnd event notifies the application when a file arrives, and OnGetUploadDir lets it choose the destination directory per upload.

Dragging Files onto the Browser

Users can drag files — and entire folders — from their desktop onto the session page. The browser notifies the application through the SDK events:

Event When it fires
OnDragFile2 While the drag is in progress. It reports the action (start, over, drop, cancel), the position, and the file names, and lets the application accept or reject the drop.
OnDropFile When an accepted drop happens. It reports the position, the file names and sizes, and lets the application exclude files from the upload.

When the application accepts the drop, the dropped files are uploaded — folders are traversed and their files included — and the application decides what to do with them, such as opening them or moving them to their final location. Files land in the session’s staging area, the Shared Files Folder, unless the application chooses another destination.

Drag and drop requires the application to handle these events; the public GitHub repository includes a drag and drop demo.

Read more