Hi,
Does anyone know how to convert a document stored in appian to an url? to use it as a dynamic link in a json.
Thanks!
Discussion posts and replies are publicly visible
Can you tell us a bit more about your use case? I'm unclear what approach you're even going for here. If, for instance, you want to allow a user to download the file from an Appian interface, you'd use the Document ID in a Document Download Link (preferably in a Rich Text Display), wherein they'd be able to click that link and download it. Appian handles the URL creation involved, ther isn't really a way to manually construct such a URL directly.
and there's any way you can save that download url? In case anyone else wants to download the document just with an url, not using the document download link.
Downloads are only available to a logged-in user viewing an active interface. There's no supported way to grab an externally-usable URL for a document download, as Appian requires that downloads are only accessible by users in the proper security roles/groups.
This method is not sanctioned by Appian but it will work if you share it with someone who is authenticated.
a!localVariables( local!documentDownloadLink: a!documentDownloadLink( document: cons!NZC_CSO_IMAGE_DOCUMENT_ID ), local!urlPrefix: "https://<APPIAN_URL>/suite/rest/a/content/latest/", concat( local!urlPrefix, local!documentDownloadLink.@attributes.@anyAttribute._documentDownloadLink, "/o" ) )
Got it, thanks!
Be aware that this is part of the internal implementation and can stop working any time.
BTW, providing a file for download is pretty simple. Just create a web API in Appian. This uses official functionality, is stable and easy to use.
Stefan is right. Much cleaner to use the API. It even works right out of the box. The only change you might need to do is to modify the extension safe list.
local!extensionWhitelist: {"pdf", "txt", "png", "jpg", "jpeg"},
Unknown said:This uses official functionality, is stable and easy to use.
This method of creating the link allows anyone with the link to download the file, correct?
Depends on who is "anyone". The user needs a valid Appian account, and have permission to call the API and have access to the document. And, as the API does not directly support logging in or SSO, the user needs to be logged in already.