Any Embeddable Document Viewer

丶灬走出姿态 提交于 2019-12-05 21:13:12

First you must understand that when the user's browser displays some file/content, it is already on the user's machine. It has been downloaded already. There is no magic "the content stays on the server, but the user can see it". Data are always transferred from the server to the user, and the user can make the data stay on his machine - one way or another.

If you understood this, you have several options:

  • You do not care about the user having the file. This is the most sane option. All other methods are some sort of "DRM" which users hate.
  • Transfer the data the user shall see to the browser only:
    • generate an image of the part of the document the user is looking at and send that to the browser. The user has no text data and needs to do many requests to get all of the document downloaded.
    • write a browser plugin (java, flash, javascript) that reads encrypted documents from the server, unencrypts them (again, on the user's machine - which means he can peek into it) and displays it. This way, the user doesn't simply get the document but needs to decrypt it.

There are existing solutions, i.e. embedding slideshare presentations with disabled download option. Don't try to invent your own, especially not if you don't want to go the long way with support and continuous enhancements.

Omer

I stick with the following guidelines using google document viewer.

  • Generate the random URL address everytime for the document (using server side scripting and htaccess. I am using PHP & htaccess). This will not give anyone direct access to the file.
  • Encode the time and date (by using any server string encoding script) with the URL so that file could be accessed only for certain time (let's say 5 minutes)
  • Output file only by matching Google Document Viewer User Agent. This will only give Google Document Viewer access to that file but no one else, even if they type that address in browser.

This is still not a very secure way but does the trick for me.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!