All predicatesShow sourcedownload.pl -- Provide a button for downloading data

This module allows a button to be inserted into the Pengine output that allows for downloading data. Originally this used the data type URL. This has been disabled in recent browsers. Also considering the length limitations on URLs on some browsers we now store the data server-side and make the link simply download the data. The data is kept on the server for keep_downloads_time seconds, default 24 hours.

Source download_button(+Data:string, +Options)
Emit a button in the SWISH output window for downloading Data. The provided data is stored on the server.

Options:

filename(+Name)
(Base-)Name of the file created (default: swish-download.dat),
content_type(+Type)
Full content type. By default this is derived from the extension of the filename and the encoding.
encoding(+Enc)
Encoding to use. One of utf8 or octet. default is utf8.
See also
- https://en.wikipedia.org/wiki/Data_URI_scheme
Source download(+Request)[private]
Handle a download request.
Source save_download_data(+Data, -UUID, +Encoding) is det[private]
Save the string Data in the download store and return a UUID to retreive it.
Source download_file(?UUID, -Path)[private]
Path is the full file from which to download Name.
To be done
- We could use the SHA1 of the data. In that case we need to touch the file if it exists and we need a way to ensure the file is completely saved by a concurrent thread that may save the same file.
Source download_dir(-Dir) is det[private]
Find the download base directory.
Source prune_downloads[private]
Prune old download files. This is actually executed every 1/4th of the time we keep the files. This makes this call fast.
Source prune_dir(+Dir, +Time, +PruneDir) is det[private]
Find all files older than Time and delete them as well as empty directories.
Source clean_entry(+Dir, +Time, +File) is semidet[private]
True when Dir/File has been cleaned and is removed.