是否可以从小程序读取/写入文件
我试图从小程序读取和写入文件,因此如果我从小程序查看器运行小程序,我可以读取/写入文件,但是当我尝试从浏览器执行此操作时,我会收到安全异常。知道如何做到这一点吗?
I've trying to read and write a file from an applet so if I run the applet from my appletviewer it is possible for me to read/write a file but when I try to do it from my browser I get a security exception. Any idea how to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
可以,但您需要对小程序进行签名并获得用户的批准。
一些有用的链接:
Yes, but you need to sign the applet and get approval from the user.
Some useful links:
沙盒 JWS 应用程序。可以使用 JNLP API 服务读取和写入本地文件系统上的文件。这是一个 演示。 JNLP API 文件服务。可下载的 Zip 文件包含源代码、启动文件和构建脚本。
A sand-boxed JWS app. can read and write to files on the local file system using the JNLP API services. Here is a demo. of the JNLP API file services. The downloadable Zip file contains the source, launch file and build script.
其实没那么难。您可以对小程序进行自签名,然后它将能够在沙箱限制之外从本地文件系统读取/写入。看看下面的链接。它将向您展示如何使用 keytool 对小程序进行签名,并且该示例实际上对文件系统进行读/写操作。无需处理策略文件等。
请注意,正如 @aioobe 提到的,系统将提示用户接受证书。
it's actually not that difficult. You can self sign an applet and then it will be able to read/write to/from the local file system outside the sandbox constraints. take look at the link below. it will show you how to sign your applet using the keytool and the example actually does read/write to the filesystem. no need to muck about the policy files and such.
Note that as @aioobe mentioned, the user will be prompted to accept the certificate though.