CrushMFT Documentation

Pre-download events#

A pre-download event runs when a user asks for a file, before the first byte is sent. The download waits for it. The job of the event can prepare the file, or hand the user another file in its place.

It is used to

  • fetch a file from slow or far storage the moment somebody wants it,
  • decrypt, convert or watermark a file for the person who downloads it,
  • write down or announce a download before it happens.

Making one#

On the Events tab of the user, or of a template:

Part Set
Action Run Plugin, with CrushTask (User Defined): see Running a job from an event
Triggers Pre-Download, under "When this user…"
Condition Always, or Download from below directory for one folder
Timing & Delivery Do event immediately
the job Enabled

What the job is given, and gives back#

The job starts with one item: the file the user asked for.

When the job ends, the server looks at the items the job ended with:

  • Nothing changed: the user gets the file they asked for.
  • The job ended with another item: the user gets the last item of the job instead. A job that copies the file to a work folder and decrypts it there so hands the decrypted copy to the user, under the name they asked for.

The item can be on other storage than the file that was asked for; the server connects there for the download.

Waiting#

The download does not start until the job says it is ready. The user's program sees a transfer that has not begun yet.

  • Keep the job short. Many programs give up on a download that does not start within a minute or two.
  • The server itself gives up after 10 minutes: "PRE_DOWNLOAD event times out while waiting to start...".
  • A job that ends without another item changes nothing: the user gets the file they asked for. To refuse a download, do not rely on this event; take the permission away.

Things to know#

  • The event runs for every single file, also for each file of a folder download.
  • It runs on every protocol.
  • A pre-download event does not replace the Downloads trigger, which runs after the download and knows whether it worked. Use both when you prepare a copy before and clean it up after.