Upload Remote Files in Web-Enabled Applications

upload remote files in web-enabled appsAt first, the file handling dual behavior in a Thinfinity VirtualUI web-enabled application can appear to be a bit confusing for new developers and users who are accustomed to running the application from the desktop. It’s actually pretty simple, as you will see in this article.

Previously, we shared with you a brief summary of the file handling possibilities in Thinfinity VirtualUI apps. In this opportunity we will try to shed some light on this topic and show you how to upload remote files in web-enabled applications.

 

Getting Files from the Browser

A VirtualUI web-enabled application has the ability to open files from the own application environment, as usual, by using the standard file system dialog. But if the developer sets VirtualUI.StdDialogs to false, when a user calls the application from the browser and wants to open a file, a special dialog box will appears to allow a file upload.

 

 

Why upload remote files and not open?

When you use a web-enabled application from the browser, the communication is enabled through a server application: the Thinfinity VirtualUI Server. In this way, you are actually using the app remotely, from the Web.

So, when you need to select a file located in the browser’s device to be read by the application, you need do a file upload in order to send a file from the browser environment to the web-enabled application, which is running in the VirtualUI Server.

 

 

Activating the remote file mode

In order to activate the file upload, the developer has to set the VirtualUI.StdDialogs (for standard dialogs) attribute to false.

 

VirtualUI.StdDialogs := false;

 

To go back to using the standard Windows File Open dialog and do a common file open in the application machine or local network, the developer has to set this attribute to true. If you do this, the remote file upload will be deactivated.

 

 

Where is the uploaded file?

By default, the uploaded files are stored automatically in a public server folder (i.e. C:\Users\Public\Documents\Cybele Software\Thinfinity\VirtualUI\). Developers can retrieve  uploaded files from this folder in order to  handle them.

But if the developer wishes to use a different folder, Thinfinity VirtualUI has additional ways to upload files to any other destination.

 

 

Changing the destination folder

The VirtualUI class has an event method called OnGetUploadDir which is fired during an upload request, allowing you to change the save folder.

 

This Delphi example shows how to define it:

 

procedure TMyForm.MyGetUploadDirHandler(Sender: TObject; var Directory: string; var Handled: Boolean);
begin
  Handled := True;
  Directory := ExtractFilePath(Application.ExeName);
End;

...
...

VirtualUI.OnGetUploadDir := InternalGetUploadDir;

 

 

Another way to upload remote files

The VirtualUI class has an additional method to upload files from the browser. This method is:

 

virtualui.UploadFile(‘selected folder’);

 

Where virtualui is an instance of the VirtualUI class. This method allows you to upload files from browsers and store them into a selected folder. The UploadFile method is independent of the StdDialogs attribute status and, of course, it is not available when the application is used in desktop mode.

 

 

Conclusions

Nowadays, the Web imposes many necessary security measures which end up limiting the use of web enabled applications. Thinfinity VirtualUI manages to integrate remote file handling securely, allowing the user to perform typical operations seamlessly.

 

In an upcoming post we will cover the topic of how to send files from the application to the browser, thus completing this File Handling series.

 

 

5 thoughts on “Upload Remote Files in Web-Enabled Applications

    • You can be notified by defining the event VirtualUI.OnDownloadEnd so your custom code will be called with the full file name of the downloaded file, so you can safely delete it, for instance.

  1. Hi! Thanks for your inquiry! We’ve sent you an email with the answer.
    Anytime you have a quick question like this, feel free to open a live chat or email us for a quick response. 🙂
    Best regards,
    Mariana

  2. @Mariana:
    Could You please make this kind of info available to the public too instead of only to the one user who asked?
    I think it’s important for everyone using VirtualUI.
    It’s very inconvenient to have to ask for an email to get this info.
    If You’re in the middle of something and have a time delay of some hours or in my case a day (because of my timezone UTC+2) until I get a response, that’s a big problem.
    It would be even better to find something like that in the documentation.

    Walter

  3. I agree wholeheartedly with Walter. Would you please update the post or post another reply with the answer to Zagreus’ question? (How to know when upload is finished.)

Leave a Reply

Your email address will not be published. Required fields are marked *