Soiree provides a File Download Service that you can use to:
- Add file download features to your Soiree products
- Allow users to download files via URLs, even if they don’t have a Soiree client installed
Every downloadable file has its own set of security permissions. You may grant access to any combination of:
- Individual users within a tenant
- Groups within a tenant
- Anonymous access
Ready to get started?
Make a File Available for Download
Add the following imports to your Agent:
import com.seronix.filedownload.AddFileAction; import com.seronix.filedownload.FileDownloadPermission; import com.seronix.filedownload.FileDownloadRecord; import com.seronix.filedownload.FileDownloadService;
You must add your file’s data to the file download service. The download service can consume a java.io.File or a java.io.InputStream.
Both the addFile and addFileByReadingInputStream methods return a FileDownloadRecord that contains two important methods:
/** * @return the file's 50-character unique identifier */ public final String getFileId(); /** * @return the URL that may be used to download the file */ public String getFileURL();
Store the file’s ID in your application tables if you need a long term reference to the file.
The file’s URL can be used to download the file. Create a String node in your agent and assign the URL’s value to it. Once you do that the designer can:
- Bind the URL to a file download component to allow the file to be downloaded within the application.
- Bind the URL to a hyperlink component to allow the URL to be opened in the user’s web browser.
- Bind the URL to a text field to allow the user to copy it to the clipboard. The user can then share the URL with their friends and they can download the file too (security permitting, of course).
Don't keep the File URL in permanent storage!Your system administrator might change your server’s hostname or port and break all of your stored URLs! Store the file’s ID in your application tables. When you need the file’s URL again, call the following method to get a fresh FileDownloadRecord that contains the file’s current URL:
FileDownloadService.get(Conversation conversation, String fileId);
Download a File in a Desktop Product
This video will show you how to use the File Downloader component to download a file in a Desktop product:
Download a File Without a Soiree Client
The file URLs returned by FileDownloadRecord.getFileURL() can be accessed by any web browser. When a web browser accesses the URL the download service will examine the file’s security permissions. If anonymous access is allowed then the browser will begin downloading the file. If the file’s security permissions restrict access to certain users and groups, the download service will perform HTTP basic access authentication (RFC 1945) and will allow the user to download the file if they supply a valid username and password and the file’s security permissions allow the user to access the file.