react-file-viewer icon indicating copy to clipboard operation
react-file-viewer copied to clipboard

I am unable to view files which are stored on server.

Open akshaykashid13 opened this issue 5 years ago • 2 comments

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 issue

akshaykashid13 avatar Jan 08 '20 14:01 akshaykashid13

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}`}
/>

marcioferlan avatar Jan 16 '20 18:01 marcioferlan

https://stackoverflow.com/questions/37760695/firebase-storage-and-access-control-allow-origin

BossBele avatar Jun 14 '23 18:06 BossBele