downloadUrl

downloadUrl, function

def pure downloadUrl(path: text): text
def pure downloadUrl(hash: text, name: text): text

Returns a URL that downloads a file, either by path in the file explorer or by content hash and name.

Examples

show table "Download URLs" with
  downloadUrl("/files/report.pdf") as "ByPath"
  downloadUrl("/catalog/images.fp/item.png") as "PackedImage"
  downloadUrl("4F7259333A6795C13F1AD9E900DAA7FE", "report.pdf") as "ByHash"

Output: three URL strings that trigger file downloads.

Remarks

The path overload also accepts a filepack entry path, such as /catalog/images.fp/item.png. It downloads that entry, not the whole pack, and remains subject to file permissions. See store product images in filepacks.

The hash overload works even if the user does not have access to the file explorer or the file is no longer present there. This function is not available on try.lokad.com.

See also