Show Images (Stored on network drive) during runtime based on user input

Hi, I am working on an application that displays a file (image or PDF) to the user based on their input. The files are stored on a network drive. When the user enters a number, outsystems should search for a file (file name = user input) in a certain, static directory and display its contents.

However, I don't want to upload all the files as resources in outsystems, as I want to keep a single point of truth (if some images/PDFs need to be changed, I would need to change them in the directory AND in outsystems).

So far I manged to create a list with all file names in a give directory by using the FileSystems extension.

Thanks for your help / ideas

Cheers, Marcus


mvp_badge
MVP
Solution

Hello Marcus,

You're on the right path with the FileSystems extension - you can use it as a low level way of interacting with existing files, and you definitely don't want to keep those files as resources in your module - it would quickly be impossible to manage, since they're packed in the .oml file representing your module, ballooning it in size, and making your code management much harder.

If the file name equals the user input as you mention, you can use the File_Exists action to check for it within your folder after the user inputs data, and if it does, you can construct its path as a string (since you know the folder, directory and filename) and fetch its data with File_ReadBinary. Then it's just a matter of displaying it, but if they're always images or PDFs, most modern browsers will display it appropriately without any code on your part - you can use the Download action at the end of your flow in order to send the file to the user.

Let us know if you have any questions.


Thanks Afonso!

I've never work with binary data, therefore didn't consindert it in my use case. Your solution works perfectly, however if decided to use the Lightbox Image Widget to display the images and for PDFs the PDF Viewer Binary Widget.


mvp_badge
MVP

That's a good idea - they'll definitely improve the user experience. I believe both of them will accept binary data without any issue, so you can just chain the data you obtain from the Filesystems extension. 

Good luck with your application!

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.