Hi,
I have my file which contains some sensitive data, and I want to open this file in a new tab based on certain parameters. How can I do this?
Hi @Sanjay Sharma
You can implement this logic using JavaScript or a server action in Reactive or ODC. I will provide a simple example of JavaScript code that will let you achieve this efficiently.
First of all, you should use the Binarydata extension to convert your binary data to Base64.
For Reactive or ODC, you can create a client action for this.
Client Action-
Javscript-
(() => {
const fileName = $parameters.FileName;
const base64Data = $parameters.Base64Data;
const ext = fileName.split('.').pop().toLowerCase();
debugger;
const data = base64Data.startsWith('data:') ? base64Data.split(',')[1] : base64Data;
const mimeTypes = {
jpg: "image/jpeg",
jpeg: "image/jpeg",
png: "image/png",
pdf: "application/pdf"
};
const blob = new Blob(
[Uint8Array.from(atob(data), c => c.charCodeAt(0))],
{ type: mimeTypes[ext] || "application/octet-stream" }
);
window.open(URL.createObjectURL(blob), "_blank");
})();
Hope this Help.
Thanks
Vijay M.
Thanks @Vijay Malviya
It's working fine for me.
Please mark @Vijay Malviya comment as solution. Then the status of this topic will be Solved, the others won't come to investigate it anymore
Hi @Sanjay Sharma,
Please check out the below module. I have implemented the same.