Watermarked share folder download – system description

The download request, the preparing background job, the issue log and how watermarking at download time, in memory, works, with its limits.

The watermarked download has three steps: request, preparation (background job or the status poll), then watermarking in memory at the moment of download. Bytes move only at download time.

Data model

Table names carry the installation's own prefix in the database.

TableRole
doc_downloaddownload request: token, user, state, expiry
doc_download_itemissue log: document, classification (pdf / image / skip), unique code
doc_share_item, docthe folder's documents

Process

  1. dlrequest: the download library's request() creates a download row and a doc_download job.
  2. Preparation (the job, or the status poll after 20 s): per document a pdf / image / skip classification and a unique code in the issue log; with no watermarkable file the state is failed; the ready state is valid for 24 hours.
  3. dlstatus: polled by the client every 2 s; dlfile: watermarks in memory at download time – on every PDF page a bottom stamp and a faint diagonal repetition (FPDI), images with GD; stamp: "name (#id) | date | Confidential | CODE". One file is delivered as such, several as a streamed ZIP; non-watermarkable files are skipped and listed.
  4. doc_download background job (one-off, queued by the request): prepareQueued(50) – prepares waiting requests and closes expired ones; no bytes move here.

Permissions

  • folders download (SYSTEM) and the download library present; status and file only for one's own token (getDownloadByToken(token, user_id)).
  • Prerequisites: FPDI (PDF), GD (image).

Known limitations

On the admin side the share folder's scope (company, assigned user) is not checked, only its existence.

Related topics: watermark background job