1
let imgsrc = this.state.retrieveuploadfile.filecontent; 

<Dialog
    className=""
    open={this.state.openattachmentDialog}
    modal={false}
    autoScrollBodyContent={true}
    contentStyle={{ maxWidth: 'none' }}
    onRequestClose={this._closeDialog} >
    <div>   
        <img src={"data:image/jpeg;" + imageBase64} style={{maxWidth: '250px', margin: '15px'}}/>
                  <embed width="100%" height="100%" name="plugin" src={"data:application/pdf;" + imageBase64} />
    </div>   
</Dialog>

I have a dialog where i can list out all the attachments which are uploaded. After the successful upload of an image I am calling the Retrieve API for all uploaded images. I am receiving the response in the below format

If it is an image I need to show the image, if it's a PDF I need to show the PDF.if it's a Word I need to show the Word. Based on base64 we need to convert and show them in the UI.

You can see in the response in the filecontent property the base64 code.

How can I show a word based on base64 ?

  • Possible duplicate of [How to display image in React?](https://stackoverflow.com/questions/42395034/how-to-display-image-in-react) – Aswin Ramesh Feb 07 '18 at 08:23
  • @AswinRamesh my question is not only image same like image if i the base64 is pdf file how to fetch that – user9196877 Feb 07 '18 at 08:51

0 Answers0