react-file-viewer
react-file-viewer copied to clipboard
I am unable to view files which are stored on server.
Hello All, There are few files which are stored on server we are able to console.log the correct file path and file type. But if we pass the same file path and file type to the <FileViewer/> component it is not able to view the file. But if we pass the local files, file path and file type we are able to view the files why this is so? can anyone help me resolve this issue. I am attaching the screen shot of my code. please look into this Thanks

window.open will cause the browser to open a new window (or tab) in that url.. you should actually pass something that resolves to the file URL in the server.
Suppose your app is running at https://example.com/app and your folderpath and filename state variables reflect correctly the relative path of the file in the server, you should have something like this for the filePath prop:
<FileViewer
...
filePath={`https://example.com/app/${this.state.folderpath}/${this.state.filename}`}
/>
https://stackoverflow.com/questions/37760695/firebase-storage-and-access-control-allow-origin