513
Views
12
Comments
Is it possible to add/remove files from Resource folder in run time?
Question

 My application fetches a file(pdf/png/tif etc) as binary and I want to display it in a container widget. For that I am using Iframe. My file is in a physical location, I get the file as binary and I am planning to store it inside resource folder and when the user closes the window, I need to remove the file. Is it possible to do it in outsystems? 

Can someone point me to any instructions on how to do that?


Thanks in advance,

Anjitha Mohan

mvp_badge
MVP
Rank: #5

Hello Anjitha

Depending on the size of the image I will advise you to store in the database, instead, as it will be much simpler to deal with this.

If you want really to store, but do not want to use the database, then I'll recommend you to use a third-party service to store the images, like Amazon, or even Dropbox, etc, or at least a network folder, if you are running an on-premises installation.

Avoid saving things dynamically to the OutSystems server (even when it is possible), to prevent problems that may arise.

Cheers.

mvp_badge
MVP
Rank: #5

So, you ALREADY have the file stored.
Your problem is how to "show" it?

You can create a page that receives as an input parameter an image identification, and in the preparation, you get the file and return it using a Download node. Then you just use this as the URL for an External Image in the widget.

To get the file, you can use the FileSystem component. It is not "supported" by OutSystems, but is maintained by OutSystems staff and MVPs.

Or you just save your images to the database and show them directly using an image widget.

But there is simply no way of previewing a file (image or whatever), that is stored in a server (database is in a server), in the client browser, without downloading the resource, so, I am not understanding your question...

Cheers.

mvp_badge
MVP
Rank: #5

Hum...

I think there is no easy solution to your request...

How do you pretend to "show" the file, client side, if the browser can't access the file?

And once the browser can access the file, no matter the securities that you impose, it is in the client machine, and a more smart guy will find a way to save it locally.

He can take pictures of the image he is seeing... So, the only way to avoid someone to take the information is to prevent the person from seeing it... 

That's why I am not understanding the requirement... 

I'll ask around to see if someone understand better what you are trying to do and already have done something similar...

Cheers.

mvp_badge
MVP
Rank: #7

There is no way to show a PDF to a user without that PDF's binary data being sent to their browser.

If what you want to do is have the PDF shown in the browser's PDF reader (like Chrome often does) instead of being downloaded as a file and saved to a local file, that is a user setting: https://helpx.adobe.com/acrobat/using/display-pdf-in-browser.html

J.Ja

Rank: #1670

 wrote:

Hum...

I think there is no easy solution to your request...

How do you pretend to "show" the file, client side, if the browser can't access the file?

And once the browser can access the file, no matter the securities that you impose, it is in the client machine, and a more smart guy will find a way to save it locally.

He can take pictures of the image he is seeing... So, the only way to avoid someone to take the information is to prevent the person from seeing it... 

That's why I am not understanding the requirement... 

I'll ask around to see if someone understand better what you are trying to do and already have done something similar...

Cheers.


Thanks for your help. I will make it more clear. Please find the attached image, this is what I need. 

No matter if they take an image of the pdf or finding a way to download the file. But the client requirement is to preview it in a webpage rather than download the file to a physical folder and then open from the folder to view the file. That is what I stick on the 'preview' part.

I have created a demo screen using web previewer component. For that I have added the file in resource folder and in 'File' structure, the binary data of the resource file has given . Here I need a clarification, Instead of the resource file if I follow the below steps, could you please confirm whether I am trying to do it on the right track.

1. I have an API which will return the binary data and info (name,type etc) of the file.

2. Assign the filename , file type and file content to the 'File' Structure and will be sending as input parameter to a webblock to preview file. The webblock is similar to web previewer.

3. Here the File stucture is passed to webblock and in the Empty File Node(verifying the input File parameter),  since it is has data, it will be saved to FileCache entity.

4. The set location node will assign the location of the file.

SyntaxEditor Code Snippet

Substr(GetBookmarkableURL(), 0, Index(GetBookmarkableURL(), "/", 8, False, True)) + GetOwnerURLPath() + GetEntryURL("DocumentPreviewRenderer") + "?FileCacheGUID=" + FileCache.GUID

5. And in final step the location is given to the iframe. Here also could you please confirm the file is not uploading to any other external site. this line is little bit confusing for me <iframe src='https://docs.google.com/gview?embedded=true

SyntaxEditor Code Snippet

"<iframe src='https://docs.google.com/gview?embedded=true&url=" + Location + "' width='" + Width + "' height='" + Height + "'></iframe>"



Hope I made it clear for you..

Please verify the approach and let me know your comments on this.

Thanks for spending your time on this.


Thanks,

Anjitha Mohan


mvp_badge
MVP
Rank: #19

Hi Anjitha,

Why don't you use the pdfJS Viewer forge component? It uses Javascript to render your PDF file (doesn't save any file in the filesystem). You have access to the full source code so you can validate for yourself what it is doing. As far as I know there is no OutSystems (officially) supported way to display (or even generate) PDFs.

Rank: #21566

Hi Anjitha,


Do you already have the solution for this?


Thanks,

Lanz