Files.comp
The Files widget enables users to attach files to records in a table.
Input Parameters:
Parameters
| Parameter Name |
Description |
Default Value |
id |
Select ID. |
Undefined. |
description |
Tooltip. |
Empty string. |
value |
value to render |
Empty string. |
readonly |
can't change state if in readonly mode |
Undefined. |
from |
Files Storage location |
Undefined. |
delete_if_update |
Enable files/dirs deletion with only update permission. |
1 |
Archive path
Archive is located in directory defined with
InputFilesArchive parameters in Apache2 config files.
The tree is organized with these levels:
-
[InputFilesArchive]/[schema]/[table]/[pk]
The folder
[InputFilesArchive]/[schema]/[table] must exists with write permission to Apache user.
In
Files_Trash_dir Apache variable shows the name of the trash folder (default 'Trash').
When a file is replaced, the previous file is preserved. Each file has a version number.
When there is only one version (in old MasonSQL release), the path was:
-
[InputFilesArchive]/[schema]/[table]/[pk]/[filename]
In current MasonSQL release, the pathes are:
-
[InputFilesArchive]/[schema]/[table]/[pk]/
-
.[filename]/YYYY-DD-DD_HH:MM:SS.version.userid.digest
-
[filename] link to .[filename]/YYYY-DD-DD_HH:MM:SS.version.userid.digest
-
.[filename]/...
-
.[filename]/...
Parameters of archived file with versioning:
-
YYY-DD-DD_HH:MM:SS is the date and time of files upload
-
version is number version =1,2,3,4,...
-
userid is the id of user (table public.anagrafiche)
-
digest is MD5SUM hexadecimal checksum of file content
Current file is a link to file version. It is possible to change current version to old.
If you upload an existing file, the system detect that there is equal in archive and change current version without save another version.
Permissions
- To enable widget in the web form the form has to have
Archive permission checked in the Funzioni table.
- If
readonly option is set to 1 user can only view or download files or directories.
- The
schema/table directory and subdirectories must have read-write permissions for www-data group.
For example: drwxrwxr-x 7 root www-data 4096 mag 19 12:24 odt_reports/
Examples
Demo
Link:
Files example.
- File_List:
- File_Menu_Save:
- File_Menu_Save_Zip:
- File_Menu_Upload:
- File_Menu_Create_Folder:
Demo code:
<& /input/Files.comp,
id => 'IdWidgetFilessTest1',
from => 'demo/orders',
value => $value,
width => 400,
height => 300,
&>
Using ID Field
Example code from
/opt/masonsql/htdocs/data/public/odt_reports.mql file related to the widget:
<%method FIELDS>title, filename, id</%method>
<%method SELECT_FIELDS>title, filename, id</%method>
<%method FIELDS_DESCR>Report Title, Report Filename, Template Files</%method>
<%method FIELDS_NEW>,,</%method>
<%method id_FIELD>
<& /input/Files.comp, %ARGS,
from => 'public/odt_reports',
width => 400,
height => 300,
readonly => 0,
&>\
</%method>
<%method FORM_HEIGHT>300</%method>
<%method PRE_INSERT>
<%args>
$FIELDS_INSERT
$PARAMS
</%args>
% delete $FIELDS_INSERT->{'id'};
% delete $PARAMS->{'id'};
</%method>