directly download file from DB

Hi All,
I need to download from DB a PDF tha is stores as Base64 format
I would like to do that directly in SAIL to allow to our users to dwnload directly from the interface this document
How can I do that , is there a method ?
Thanks
Elia

  Discussion posts and replies are publicly visible

  • I would recommend against that sort of approach, as it could lead to performance issues. Instead, simply upload the file as a document in Appian, and use the a!documentDownloadLink() SAIL component docs.appian.com/.../Document_Link_Component.html to allow users to download it.
  • The closest I found is a smartservice to retrieve documents stored as base64 string from DB is this component: forum.appian.com/.../summary

    You can customize it to return a document via expression similar to how downloaddatasubset works.

    I agree with Eliot, use Appian collaboration for better performance and to follow best practice.
  • 0
    Certified Lead Developer
    do you really want to store the documents into the DB and retrieve the same from DB, because it takes a lot of time to store as well as to retrieve the document and this impact the performance too, so as you are saying that you want to retrieve the Document from DB on SAIL, so will your customer really be happy if your UI takes huge time to load, because i don't think so. However if you want the same the you can create a Custom Plugin to do that. or you can take the help of SmartService mention by
  • If the SAIL screen is a UI of User Input Task, and the user will most likely need to download the document, then using the Smart Service suggested by make the most sense. You can use the Smart Service to retrieve the document from DB into Appian document, then provide the link in SAIL UI. You should perform clean up work of deleting the Appian document, after the task or when the process is about to complete.

    If your use case is different, another approach is to create a link using another web application or custom Appian Servlet plug-in. Create the web application or Servlet in such a way that you can construct URL link from your SAIL UI to point to a specific document in the database. The document do not get retrieved or accessed in anyway until the end user actually click on the link to download. When the link is clicked, the web app or Servlet, retrieve the document for the user to download. There shouldn't be performance concerns in this approach, as the documents are not retrieved from DB until the user actually click on the link to download.
  • I have to receive many files from another system and to show them on demand , when the user need.
    If I load these files by a process, as document variable type, the risk is the process can consume a large amount of RAM
    If I have many of these instances they can slow down the whole system ...more, they stay in memory until an engines restart happens (if the instances are terminated), so a SAIL "direct download" approach if the only way I can see...
  • I don't think storing documents in the database will be longer than with Appian documents. Appian does similar work saving the document somewhere.

    The difference will be in additional time for encoding/decoding to/from base64 and bigger encoded size.

    Also, using document with link fits Appian best practice, so I second using document and SAIL link to get document content.
  • 0
    Certified Lead Developer
    in reply to eliav
    You have to factor in how big are the documents and how frequent they are downloaded.

    Both approaches have it's advantages. If immediate/on-the-fly download is not a required, I recommend via process approach. The process can be delete/archived immediately after moving the document to Appian collab.

    Direct download takes up RAM temporarily. The way the direct download works is the servlet takes document/sql parameters and retrieve and loads base64 string to RAM (JAVA heap), convert it to document stream output.
  • 0
    Appian Employee
    in reply to eliav

    I think there's a misunderstanding here. Document variables use almost no memory, since they're just ids. Giving your users the option to download documents with a!documentDownloadLink() should not be causing any performance issues. If it is, please create a support case.

  • Hello Shyam,

    I have similar requirement to download the document generated through stored proc , Can you please help me with smartservice , i am unable to open the link provided by you .

    Thanks in advance :) :)