access.md

July 26, 2024 ยท View on GitHub

Datalink manual

Write Access

When write_access is FS then 'immutable' state for a file is left unmodified. This option does not require a datalinker.

When write_access is BLOCKED then file is changed to 'immutable' state. It can't be renamed, modified or deleted neither by a normal user nor superuser. Datalink column cannot be updated, but it can be set to null to unlink the file.

When write_access is TOKEN then file is changed to 'immutable' state. Datalink column can be updated when appropriate write token is present. For example, write token is included in a datalink generated by DLNEWCOPY() function.

mydb=# UPDATE my_table SET link=DLNEWCOPY(link);

There is also a utility SQL function datalink.write_text() which does this for you and also lets you replace file contents atomically and transactionally.

mydb=# UPDATE my_table SET link=datalink.write_text(link, 'New content!!!');

New file is created each time. Original file will be replaced with the new version by the datalinker when the update transaction commits. If the transaction is aborted, the file will not be replaced.

When write_access is ADMIN then file is changed to 'immutable' state. Datalink column can always be updated.

mydb=# UPDATE my_table SET link=DLVALUE('file:/var/www/datalink/test2.txt');

Read access

When read_access is FS then file owner and mode are left unmodified. This option does not require a datalinker.

When read_access is DB then file owner and mode are changed to a value, configured in the datalinker, normally postgres.www-data and 0440. This makes file effectively owned and readable by the database server and also the web server (apache).

One can read such files with the use of datalink.read_text() SQL function.

Read access can be further filtered with the use of (Datalink File Filter)[dlff.md].

Also provided is a mod-perl handler for apache web server, which authenticates access for filenames containing read access tokens. This lets you make links to your files with the DLURLCOMPLETE function.

Also provided is a dlcat shell command, which authenticates access for filenames containing read access tokens. This lets you access the content of files with the help of DLURLPATH function.

Datalink manual