Set Up File Download
Now that we have setup file upload, we also need to have the ability to download or open those files from
the database. In this example, we will edit the All Employees operation and add another derived FD called
d_view_files.
SELECT 'Upload File' AS d_upload_files,'View Files' AS d_view_files, empno, firstnme, lastname, edlevel, image
FROM pjdata.employee
Now, we need an associated operation which will show all the files associated with a particular employee. Create
an Association 1-Many operation to show all files associated with the selected employee.
SELECT * FROM wowsamples.employeefiles WHERE employeenum = ??empno
Associate this operation with d_view_files FD. Then, run the All Employees operation. Now there is an "All Employee
Files" link which can be clicked on to see all of the employees' files.
After viewing all files, we need to create a file download operation to actually download the file to the local computer
from the blob field. Create a new operation of type File Download and select the relevant record from the employeefiles
table.
SELECT * FROM wowsamples.employeefiles WHERE id = ??id
Now that the download file association is created, we can associate it with the "View Employees Files" operation,
specifically, the file_name FD.
Now, when a user clicks on the field name they will be prompted to download the file to their local file system.