Upload document to a URL from which it can be downloaded

Hello, I'm building a web app in which I need to upload a dynamically created Excel sheet based on the current screen's data which needs to be read on the following screen, specifically in a URL path format (www.example.com/excel.xlsx), which means I need to be able to download the document straight upon accessing the URL.

Is there any way to upload a document to the server and have a direct download URL? I tried using the Google Drive component on the Forge but it requires user authentication which I don't want.

Hi Kazymir

Have you created an uploaded entity?
if not, create an upload entity so that you can upload according to the file name, file type then you have to link the link so that it can get the link redirected
Cheers

norton 1122 wrote:

Hi Kazymir

Have you created an uploaded entity?
if not, create an upload entity so that you can upload according to the file name, file type then you have to link the link so that it can get the link redirected
Cheers

I don't quite understand what you mean about the linking, can you elaborate? Also I want to store the file itself, not just convert the data from excel to record list.

Hi Kazymir,

As with all data you want to store, you need to use the database. Whether the user uploads a file, or you create the file yourself, if you want it available on a later time (even if "later" is just a few seconds), you need to store the binary in the database.

Once it's in the database, you can create a download page that has a parameter with some GUID that's associated with the file, and retrieve the file in the Preperation, and end the Preperation with a Download.

Kilian Hekhuis wrote:

Hi Kazymir,

As with all data you want to store, you need to use the database. Whether the user uploads a file, or you create the file yourself, if you want it available on a later time (even if "later" is just a few seconds), you need to store the binary in the database.

Once it's in the database, you can create a download page that has a parameter with some GUID that's associated with the file, and retrieve the file in the Preperation, and end the Preperation with a Download.

Hi Kilian,

Thanks for the answer, however I'm afraid I still seem to be stuck because of this issue. Let me explain what I'm trying to do in a bit more detail:

I am using an external web tool to display my data in a certain way. The issue is that I'm implementing this tool through HTML scripts on the page, and it can only use this URL format (www.example.com/excel.xlsx) as input for the data . The file name must also be hardcoded in my HTML scripts as it will always be fetching the same file, just that the file would contain different data. 

I've stored my data in the database but I'm struggling to understand the next step and what you mean by using a GUID or how I would retrieve the direct download URL from it. Could you explain further?

Thank you.

Did you manage to do this? If so I would appreciate some guidance as I'm having a similar issue where I need to store a PDF and somehow having an url to access it to feed it to a mobile plugin that will visualize it in app. It's incredible the lack of information on this issue in outsystems.

Hello Pedro,

Why do you think there's a lack of information on this issue? OutSystems is built in a way that leads users to store everything in the database - which is not a bad thing. But, as with everything in life, there are pros and cons.

There is the FileSystem extension that might allow the user to store certain files in the server but I strongly advise against that. In disaster recovery scenarios, having everything in the DB makes the process easier. If you decide to put business data outside of it, it might not be recovered.

As such, two suggestions:

- Have you tried to create a screen that receives an id and "downloads" the file in the preparation? If you pass that to your mobile plugin, does it work as intended?

- Not sure if an S3 bucket would do the trick, but have you tried to approach this solution or something similar?

Let us know if this helps somehow.


Cheers!


Hello Pedro.

This is not an OutSystems issue. It all depends on what you have in mind.

The same way you found this topic, you could have crossed this one. As you see, each person has some way of doing it. Because my first component was a file storage system, I'm familiar with the topic.

You can create a page that receives a file id as a parameter and returns the document. I've done it countless times in Tradicional Web.

The page can be anonymous (everyone can get the files) or use the default Roles or even some new logic you decide to implement.

The download action can be customized to any filename or mime-type, and if you select "Save To Disk=No" it will open the file in browser as you wanted.

I've created this quick example to show how easy it is.


Or are you looking for a Reactive way of doing it? It is basically the same logic, with a few more warnings.

Kazymir Rabier wrote:

I am using an external web tool to display my data in a certain way. The issue is that I'm implementing this tool through HTML scripts on the page, and it can only use this URL format (www.example.com/excel.xlsx) as input for the data . The file name must also be hardcoded in my HTML scripts as it will always be fetching the same file, just that the file would contain different data. 

I've stored my data in the database but I'm struggling to understand the next step and what you mean by using a GUID or how I would retrieve the direct download URL from it. Could you explain further?

Thank you.

Probably you don't need a file for the data, you just need an URL that will return a byte stream that can be parsed by the tool. If that is the case, you can expose a REST Endpoint that will return a binary on a given "filename" (or ID) and pass that as the URL. 

You can also use the approach mentioned before of using the download in the preparation.

Cheers!

Nuno Reis wrote:

Hello Pedro.

This is not an OutSystems issue. It all depends on what you have in mind.

The same way you found this topic, you could have crossed this one. As you see, each person has some way of doing it. Because my first component was a file storage system, I'm familiar with the topic.

You can create a page that receives a file id as a parameter and returns the document. I've done it countless times in Tradicional Web.

The page can be anonymous (everyone can get the files) or use the default Roles or even some new logic you decide to implement.

The download action can be customized to any filename or mime-type, and if you select "Save To Disk=No" it will open the file in browser as you wanted.

I've created this quick example to show how easy it is.


Or are you looking for a Reactive way of doing it? It is basically the same logic, with a few more warnings.

Hello all, I was surprised by the fast responses and I thank you all for that!

I had seen that post but I hadn't tried it because I was thinking I would need an url already of the pdf and not the download, I was already using that REST aproach to download the file, what works great on the browser but not on the mobile.

I gave a try to that web page based on the oml your gave me and the url worked as intended on the browser but when I put it's url on the plugin, the plugin rendered the html of the source page, both on browser device preview and mobile. So I put the url directly in a iframe and it worked on the browser preview of the device!


I got happy, but when i tried it on the real phone, it did not work...

Tried another fancier iframe as explained here and doesn't work.

Any more sugestions?

And again, thank you all for your time and availability!

Hi.

I'd assume working on preview it would work on phone. Logged in with the same user and all?

What do you mean by "did not work"? Did it showed an error on screen?


Nuno Reis wrote:

Hi.

I'd assume working on preview it would work on phone. Logged in with the same user and all?

What do you mean by "did not work"? Did it showed an error on screen?


Yes, same user. It simply doesn't render anything, no error.


Try with Save To Disk = Yes to see if you can receive the file.

It can be an issue with your pdf reader in browser.

Nuno Reis wrote:

Try with Save To Disk = Yes to see if you can receive the file.

It can be an issue with your pdf reader in browser.

With that option: in the browser asked me to save the file, wich I did, than nothing happened, same as before, in the mobile it did nothing.

Went back to a normal iframe with the src being that url, again works on the browser but not in the mobile, what can possible be. And the link is https.


I'm searching for similar situations and there are a lot of complaints online related to iframe and smartphones. This doesn't seem like an OutSystems issue.

Can you not do it in an iframe?


Nuno Reis wrote:

I'm searching for similar situations and there are a lot of complaints online related to iframe and smartphones. This doesn't seem like an OutSystems issue.

Can you not do it in an iframe?


I'm not seeing how I'm gona open the url of the Tradicional Web that is downloading the pdf without an iframe


Pedro,

The Traditional Web screen you are using to download the PDF will return a file, that's all... what you do with it on your device/application is something else altogether.

You may want to try one of these components to preview PDFs on mobile apps:

This may also be a possibility to download the file (and then use the device's builtin previewer?):

Hope this helps.