I have a MERN site where the user can upload files like docx, pdf, and then they are uploaded to mongoDB using gridfs. I want the user to be able to select a file they have previously uploaded and view it in the browser (embedded). I have it to the point where I have the dataURL for the file, but I cannot get it to display.
Here is an example dataURL I've generated for a file the user selected:
data:text/xml;base64,UEsDBBQACAgIAC+LZ1IAAAAAAAAAAAAAAAASAAAAd29yZC9udW1iZXJpbmcu
eG1srVbbjpswEP2C/gNC6mPCJYRQtGQfutqq1apabbcf4Bg....
And this code goes on for a long time.
Here is what I'm using to display it ( {data} is just the variable I am using for the dataURL as seen above):
<object
data={data}
type='text/xml'
title='essay-view'
id='essay-view'
></object>
This is what is showing up on the page where the <object>
should be:
It is a encoding or decoding issue? I've tried overriding the mimetype in the dataURL, but no luck. I'd like this to display the file, no matter if it's a pdf or docx, but formatting isn't super important.