webodf / ViewerJS

ViewerJS: Document Reader in JavaScript
http://viewerjs.org
1.94k stars 421 forks source link

Does ViewerJS render files located from network shared folder (UNC path)? #240

Closed Juniuz closed 6 years ago

Juniuz commented 6 years ago

Hi there,

I have used ViewerJS in my web app and the library is perfect for viewing pdf files in the browser. The document files that are being rendered are saved inside a folder that reside in the web root folder of the web server. Having said that, my web app also requires to load/render files located from a network shared folder. Is this doable in ViewerJS?

Example below are links that is used to load pdf file

http://server/myWebApp/ViewerJS/#../files/testfiles/lab_report_test.pdf - lab_report_test.pdf file is saved in files/testfiles folder path inside the web root folder. This works correctly.

However, this link http://server/myWebApp/ViewerJS/#\\server2\main\transfer\test\lab_report_test.pdf file is located in a network folder path \\server2\main\transfer\test. This path doesn't render the pdf file.

Any help is greatly appreciated.

vandenoever commented 6 years ago

The file needs to be on the same server or you have to use CORS.

If you want to serve files from a different server, you have to request those files via a path on the same server as you are on. For example: //get_from_network?path=\server2\main\transfer

So you need to write a custom component on your server to proxy to the files. This is a limitation because of web security.