File (value of type)

From JRapid

Jump to: navigation, search

file is a value of type.

Contents

Description

File is a built-in type used to create properties that store files.

The file type generates a default UI widget with file upload and download features. The rest of the application layers handle the file properties as string. The application stores the path to the uploaded file.

Files are stored in the location specified by the default.repository property in the jrapid.properties file. In that repository folder, a directory is created with the name of the entity that holds a file type property.

When a file is uploaded using an entity's form, the file is stored in a three level directory structure generated in the repository folder using the first three characters of the filename. The file is renamed, adding a hash value to the beginning of the name, followed by an exclamation mark (!) and the original filename.

The application maps requests to URLs starting with /upload/ to a servlet that accesses the application repository to retrieve the files.

Usage

<property
    ...
    type= "file"
    ...
/>


Examples

A simple example shows how easy is to get file upload and download functionality in your form by just defining a file property.


 <entity label="Document" name="Document">
        <property display="primary" label="Title" name="title"/>
        <property label="Description" name="description" type="text"/>
        <property label="File" name="docFile" type="file"/>
 </entity>

The form is generated with the default file widget.

File property example‎

The database table and server side application layer for the docFile property handle the data as a string. For the "mydocument.doc" file in the example, the upload location would be:

REPOSITORY/Document/m/y/d/d365e0123963408b!mydocument.doc

The docfile property of the Document entity stores the value "Document/m/y/d/d365e0123963408b!mydocument.doc".

This file may be requested through /upload/Document/m/y/d/d365e0123963408b!mydocument.doc.

See also

Personal tools