How to download attachment from record form?

Hi,

I'm looking for help to download the attachment from record form, I already made where to upload, there are multiple files/docs so I made with forge component Multiple File Upload. But, when I enter the detail form page, the attachment doesn't show the files/docs. 

And how to download it, if the attachment appears?

Thanks

Dear Ayu,


https://success.outsystems.com/Documentation/11/Reference/OutSystems_Language/Logic/Implementing_Logic/Web_Logic_Tools/Download

you can use the Download component as shown below to download the file. If you have saved the data in binary it is straight forward,  use the binary column as file content  and mime type as "application/octet-stream" and save to disk to yes. It will download the file for you. 


Thanks


Mohamed wrote:

Dear Ayu,


https://success.outsystems.com/Documentation/11/Reference/OutSystems_Language/Logic/Implementing_Logic/Web_Logic_Tools/Download

you can use the Download component as shown below to download the file. If you have saved the data in binary it is straight forward,  use the binary column as file content  and mime type as "application/octet-stream" and save to disk to yes. It will download the file for you. 


Thanks


Hi Mohamed, Thanks for the reply.

What is Base64Binary? It's logic for what?

-

New page:

Detail page:

I want to download the attachment at detail page, but the file I uploaded doesn't appear

Thanks 



Dear Ayu,


Its not clear what you meant by the detail page, How do you handle the saving these files?. 


For base64tobinary, please follow the below link. 


https://success.outsystems.com/Documentation/11/Reference/OutSystems_APIs/BinaryData_API?origin=d

Thanks



Ayu Andini wrote:

Detail page:

I want to download the attachment at detail page, but the file I uploaded doesn't appear

Do you load your attachments list from the database on a Preparation stage?

When designing this approach you should consider the following rules:

  1. When saving a document with attachments you should first save your document (and know its Id).
  2. When saving files you should attach them to the document they are uploaded along with (have a DocumentId attribute with the Document Identifier type, this attribute should be saved for every file and should match the document identifier from step 1).
  3. When showing detail page you should load your document and files list on a Preparation stage (file list should be filtered by the document identifier)

And to actually download the file - it depends on the way you store files on the database. One approach is to store binary data directly in an attribute of an Entity. Another approach is to store Base64-encoded file in a Text attribute of an Entity and than decoding it back to binary right before downloading.