189
Views
16
Comments
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.

Rank: #12986

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

mvp_badge
MVP
Rank: #2

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.

Rank: #3358

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.

mvp_badge
MVP
Rank: #57

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!


mvp_badge
MVP
Rank: #69

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.

DownloadExample.oml

mvp_badge
MVP
Rank: #69

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?


mvp_badge
MVP
Rank: #69

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.

mvp_badge
MVP
Rank: #69

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?


mvp_badge
MVP
Rank: #18

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.