1) Simple File Handling
You want to add upload functionality to your application.
Multiple File Upload
To build this functionality the following steps have to be taken.
Define a connection name and distinguish whether it should be in memory or on a file system. In this cookbook it will be 'connection1' which uploads files to a file system. The aquima.properties file has to be extended by the following entry:
connection.connection1.file.path=D:/AQ_File_Upload
- Create an entity 'File' in your model.
- Create at least one attribute: File.Id. For convenience add also File.Name, File.Type and File.Size.
- Create an event called 'UploadAction'.
- Create an exposed flow.
- Create a page which is put in the flow and is connected.
Create a container of type AQ_File_Upload (and put it at the page) with the following parameters:
Parameter Value Comments Connection connection1 Persistence Temporary Mode Multiple files FileInstance File The name of the entity defined in step 2. FileID File.Id FileName File.Name FileType File.Type FileSize File.Size - Click the tab 'Events' and select the event 'UploadedAction' at the 'FileUploaded' parameter.
- Create a container of type AQ_InstanceSelectorPlus.
- Let the containment be:
- File.Id, File.Name, File.Type, File.Size, all of them read-only
- A button 'Delete' (with a corresponding event, connect it in the flow with the AQ_File_Delete service)
- A download container (see 'Download File')
- Let the parameters be:
Parameter 'entity' should be 'File'.
- Let the containment be:
- Let the instance selector container be the second container on the page.
Download File
To get the download file container work, first create a text item with the name 'DownloadText' and enter some text, e.g. Download.
Create a AQ_File_Download container and add the following parameters:
Parameter | Value |
---|---|
Connection | connection1 |
FileId | File.Id |
ButtonText | DownloadText |
Delete File
Create a new service of type 'AQ_File_Delete'. Enter the following parameters:
Parameter | Value |
---|---|
Connection | connection1 |
FileId | File.Id |
Runtime
<screenshot>
2) Advanced File Handling