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:
    FilesExample.png

  • File_Menu_Save:
    Files_menu_save.png

  • File_Menu_Save_Zip:
    Files_menu_save_zip.png

  • File_Menu_Upload:
    Files_menu_upload.png

  • File_Menu_Create_Folder:
    File_menu_Create_Folder.png

Demo code:

<& /input/Files.comp,
  id => 'IdWidgetFilessTest1',
  from => 'demo/orders',
  value => $value,
  width => 400,
  height => 300,
&>

Using ID Field

UsingFields.PNG

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>
I Attachment Action Size Date Who Comment
File_menu_Create_Folder.pngpng File_menu_Create_Folder.png manage 13 K 14 Apr 2016 - 15:36 DipenPatel File_Menu_Create_Folder
FilesExample.pngpng FilesExample.png manage 6 K 12 Apr 2016 - 17:56 DipenPatel Files Example
Files_menu_save.pngpng Files_menu_save.png manage 12 K 14 Apr 2016 - 14:37 DipenPatel File_Menu_Save
Files_menu_save_zip.pngpng Files_menu_save_zip.png manage 10 K 14 Apr 2016 - 14:38 DipenPatel File_Menu_Save_Zip
Files_menu_upload.pngpng Files_menu_upload.png manage 13 K 14 Apr 2016 - 14:38 DipenPatel File_Menu_Upload
UsingFields.PNGPNG UsingFields.PNG manage 9 K 19 May 2016 - 15:02 JanezStangelj  
Topic revision: r11 - 22 Apr 2018, GuidoBrugnara
This site is powered by FoswikiCopyright (©) Leader.IT - Italy P.I. IT01434390223 Privacy policy & use of cookies