简体   繁体   中英

How to display base64 file in react in cross browser fashion

Currently, I am getting a json file containing base64 encoded files. The types varies from pdf, docx, jpg, etc.

I have a look at different options:

They need physical files to feed into the component, in order to display. https://www.npmjs.com/package/react-file-viewer

https://www.npmjs.com/package/react-iframe

I have looked at iframe and anchor. It works in Chrome. IE and Firefox has security control so I cannot append data into iframe.src or a.href.

Also I heard that chrome has 3mb limit for base64 data

Any suggestion will be appreciated

react-file-viewer接受 dataUrl,因此您可以直接使用 base64 编码的文件。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM