A new script service is available to check if a temporary resource exists and to get its URL:
{{velocity}}
#set ($tempResourceReference = ...)
#if ($services.resource.temporary.exists($tempResourceReference))
[[Download>>path:$services.resource.temporary.getURL($tempResourceReference)]]
#end
{{/velocity}}
#set ($tempResourceReference = ...)
#if ($services.resource.temporary.exists($tempResourceReference))
[[Download>>path:$services.resource.temporary.getURL($tempResourceReference)]]
#end
{{/velocity}}