hPreFileDownload

This hook allows plugins to observe file downloads. It is called for file downloads and requests for thumbnail images, both from the normal platform interface and from the web publisher.

When observing file downloads, at the very least, your plugin should check the isThumbnail and transform arguments to make sure you are observing the right thing. You might also need to check the isWebPublisher argument.

This hook should not be used to implement access control or security restrictions.

This hook may not be called if the file can be served from the browser’s cache.

If the plugin sets the redirectPath response property, the file download will not be audited.

Arguments

Name Type Description
file File The file being downloaded
transform String A string specifying the requested transform, or the empty string if none requested.
permittingRef Ref The ref of the object which contained a file identified and was readable by the user, permitting this download. May be null.
isThumbnail boolean true if the request is for a thumbnail image
isWebPublisher boolean true if the request is file or thumbnail requested through a std_web_publisher publication
request Request Information about the HTTP request for the file

Response

Return information by changing these properties of the response object.

Name Type Description
redirectPath String If set, the user will be redirected to this path instead of downloading the file

JavaScript template


P.hook('hPreFileDownload', function(response, file, transform, permittingRef, isThumbnail, isWebPublisher, request) {
    // Respond to hook, for example
    // response.redirectPath = ...
});