You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 17 Next »

File Handling

You want to add upload functionality to your application.

Configurations

in aquima.properties

in messages_en-GB:

#fileupload
fileupload.label.single=Add file...
fileupload.label.multi=Add files...
fileupload.description.filesize=Maximum file size is: {0}
fileupload.description.extension=Allowed file extensions are: {0}
fileupload.validation.extension=File type not allowed
fileupload.validation.filesize=File is too large
fileupload.status.succes=File(s) uploaded successfully
fileupload.status.failed=Upload failed because the following file(s) do not meet all conditions:

 

Multiple File Upload

To build this functionality the following steps have to be taken.

  1. Define a connection name (or as in the example project two connections) and distinguish whether it should be in memory or on a file system. In this cookbook 'connection1' and 'connection2' will be used: connection1 uploads to the memory, connection2 to the file system. The aquima.properties file has to be extended by the following entries:

    connection.connection1.memory
    connection.connection2.filesystem.path=C:/UploadedFiles/
  2. Create an entity 'File' in your model.
  3. Create at least one attribute: File.Id. For convenience add also File.Name, File.Type and File.Size.
  4. Create an event called 'UploadAction'.
  5. Create an exposed flow.
  6. Create a page which is put in the flow and is connected.
  7. Create a container of type AQ_File_Upload (and put it at the page) with the following parameters:

    ParameterValueComments
    Connectionconnection1 
    PersistenceTemporary 
    ModeMultiple files 
    FileInstanceFileThe name of the entity defined in step 2.
    FileIDFile.Id 
    FileNameFile.Name 
    FileTypeFile.Type 
    FileSizeFile.Size 
  8. Click the tab 'Events' and select the event 'UploadedAction' at the 'FileUploaded' parameter.
  9. Create a container of type AQ_InstanceSelectorPlus.
    1. Let the containment be:
      1. File.Id, File.Name, File.Type, File.Size, all of them read-only
      2. A button 'Delete' (with a corresponding event, connect it in the flow with the AQ_File_Delete service)
      3. A download container (see 'Download File')
    2. Let the parameters be:
      1. Parameter 'entity' should be 'File'.

  10. 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:

 

ParameterValue
Connectionconnection1
FileIdFile.Id
ButtonTextDownloadText

 

Delete File

Create a new service of type 'AQ_File_Delete'. Enter the following parameters:

ParameterValue
Connectionconnection1
FileIdFile.Id

 

Runtime

<screenshot>

 

 

There is no content with the specified labels

  • No labels