Download File From Certain Directory in the Server

Download File From Certain Directory in the Server

  

Hi Guys,

I created an Upload facility with the help of filesystem. Now it seems that it does not have the ability to download the file uploaded from the Server.

Can you please help how to achieve the ability to download the file from a certain directory in the server?

Hi Michael,


The logic you are using is for downloading file dynamically for which you have binary data available. 

You need to pass File Content in form of binary format and File Name of Output file.
So you can not use this if you have ready file in some URL and you just need to download it.

In the simplest way, what you can do here is provide a link with href and link your file url inside it.
HTML 5 has some cool features and one of them is file download using a link(You need file URL for this).
Check this link for the same.

In the other way, you can use some simple file transfer plugins available in forge to download your file with URLs.
You can also point your download url with External URL link and it will open/download the file for you.

Regards,
Palak Patel

Hi Michael,

It's probably best to use the Network Filesystem plugin for this one if you have a complex infra structure with load-balanced servers.

Matthias Preuter has written one like 8 years ago.
https://www.outsystems.com/forge/component/99/network-filesystem/

This one might also work if you want to retrieve the file local:
https://www.outsystems.com/forge/component/68/filesystem/


Palak and Erik,

Before I posted this here is what I did. I created a table with the ff: columns. See below picture


I use the filesystem from forge. Everytime the user upload a file I use the filewritebinary to upload the file to a certain directory and after every upload I insert a record into the table above with the filepath and filename values in it, except for the binary data.


Can i use those values in the table to achieve my goal? Now I am stock on how to download the file that I uploaded in the directory



Solution

Hi Michael,

Like Palak Patel mentions, the Download tool needs to be passed the contents of the file to download (will be BinaryData).

Before you can download the file, you need to use the (Network)FileSystem extension again, this time to read the contents of the file from the server's filesystem (you have the path where you previously saved it stored in your DocumentUpload table), and pass those contents as the File Content of the Download tool. As for the File Name, I suggest you remove the Path + you have there and leave just the FileName part.

Hope this helps!

Solution

Jorge Martins wrote:

Hi Michael,

Like Palak Patel mentions, the Download tool needs to be passed the contents of the file to download (will be BinaryData).

Before you can download the file, you need to use the (Network)FileSystem extension again, this time to read the contents of the file from the server's filesystem (you have the path where you previously saved it stored in your DocumentUpload table), and pass those contents as the File Content of the Download tool. As for the File Name, I suggest you remove the Path + you have there and leave just the FileName part.

Hope this helps!

Palak, Eric, and Jorge,

It's working now. Thank you for the ideas.

cheers