Is it possible to add/remove files from Resource folder in run time?

 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

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.

Eduardo Jauch wrote:

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.

Thanks for your response.

We are having on-premise installation and the file is saved in a network location. Could you please explain the approach for showing the file inside a container from the network location. Also if I store the file in database, how can I preview the file without downloading. Our client will not allow to use external plugins not supported by outsystems.


Thanks,

Anjitha Mohan


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.

Eduardo Jauch wrote:

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.

Yes.. The files are saved in a network location and I need to show a pdf file in the webpage. I meant the file should not be downloaded to the user's machine. I have gone through the logic of Web previewer forge component which is using iframe to preview the files. The requirement is exactly the same in web previewer. But it uploads the files to https://view.officeapps.live.com which I cannot use because of security reasons. 

Please let me know if you have a better approach on this. 


Thanks,

Anjitha Mohan


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.

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

 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


Justin James wrote:

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

Thanks for you help.. I will try this..


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.

Hi Anjitha,


Do you already have the solution for this?


Thanks,

Lanz

Lanz Buzz wrote:

Hi Anjitha,


Do you already have the solution for this?


Thanks,

Lanz

Not yet. I don't have a solution to add/remove files from Resource folder in run time. But my requirement is to preview a pdf file in browser, for that I got a solution using iframe.



Anjitha Mohan wrote:

Eduardo Jauch wrote:

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.

Yes.. The files are saved in a network location and I need to show a pdf file in the webpage. I meant the file should not be downloaded to the user's machine. I have gone through the logic of Web previewer forge component which is using iframe to preview the files. The requirement is exactly the same in web previewer. But it uploads the files to https://view.officeapps.live.com which I cannot use because of security reasons. 

Please let me know if you have a better approach on this. 


Thanks,

Anjitha Mohan


Dear Anjitha,

As  i understand your requirement that you already have the .pdf files saved on network location.

You just wanted to show them in the browser without downloading it.

1: Did you tried the Destination property of a button click. In URL give your .odf file's url 


2: Option is to create another screen and put the iframe on it and give your pdf url as SourceURL of iframe.


Regards,