科尔多瓦:从VS 2017使用--allow-file-access-from-files启动chrome [英] Cordova: Launching chrome with --allow-file-access-from-files from VS 2017

查看:122
本文介绍了科尔多瓦:从VS 2017使用--allow-file-access-from-files启动chrome的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Visual Studio 2017中的cordova应用程序,并且尝试使用文件插件访问文件系统.不幸的是,当使用在浏览器中模拟"(使用cordova-simulate)调试应用程序时,这不起作用.

I'm working on a cordova application in Visual Studio 2017 and I'm trying to access the filesystem using the file plugin. Unfortunately this does not work when debugging the application using 'Simulate in browser' (using cordova-simulate).

安全错误:已确定某些文件对于Web应用程序内部的访问是不安全的,或者正在对文件资源进行太多调用."错误.

A 'SecurityError: It was determined that certain files are unsafe for access within a Web application, or that too many calls are being made on file resources.' error is raised.

我猜是否必须将'--allow-file-access-from-files'选项传递给chrome,但是我不知道该怎么做,因为chrome是在新窗口中自动启动的,我找不到Visual Studio中的任何配置选项.

I guess if have to pass '--allow-file-access-from-files' option to chrome, but I don't know how to do this, because chrome is launched automatically in a new window and I cannot find any configuration options in Visual Studio.

推荐答案

一些 Chrome怪癖是:

  • 设备就绪事件发生后,Chrome文件系统尚未立即就绪.解决方法是您可以预订filePluginIsReady事件. 示例: javascript window.addEventListener('filePluginIsReady', function(){ console.log('File plugin is ready');}, false);您可以使用window.isFilePluginReadyRaised函数检查事件是否已经引发.
  • window.requestFileSystem TEMPORARY和PERSISTENT文件系统的配额在Chrome中不受限制.
  • 要在Chrome中增加持久性存储,您需要调用window.initPersistentFileSystem方法.永久存储配额默认为5 MB.
  • Chrome需要-allow-file-access-from-files 运行参数以通过file:///协议支持API.
  • 如果在获取现有的Entry时使用标志{create:true},则不会更改
  • 文件对象.
  • Chrome filesystem is not immediately ready after device ready event. As a workaround you can subscribe to filePluginIsReady event. Example: javascript window.addEventListener('filePluginIsReady', function(){ console.log('File plugin is ready');}, false); You can use window.isFilePluginReadyRaised function to check whether event was already raised.
  • window.requestFileSystem TEMPORARY and PERSISTENT filesystem quotas are not limited in Chrome.
  • To increase persistent storage in Chrome you need to call window.initPersistentFileSystem method. Persistent storage quota is 5 MB by default.
  • Chrome requires --allow-file-access-from-files run argument to support API via file:/// protocol.
  • File object will be not changed if you use flag {create:true} when getting an existing Entry.

上面的古怪表格使用基本步骤此处:

Form above quirks use basic steps here:

在撰写本文时,Chrome浏览器具有FileSystem API的唯一有效实现.尚没有用于文件/配额管理的专用浏览器UI.要将数据存储在用户系统上,可能需要您的应用程序请求配额.但是,为了进行测试,可以使用-unlimited-quota-for-files 标志运行Chrome.此外,如果您要为Chrome网上应用店构建应用或扩展程序,则可以使用 unlimitedStorage 清单文件权限代替请求配额.最终,用户将收到一个权限对话框,以授予,拒绝或增加应用程序的存储空间.

At the time of writing this article, Google Chrome has the only working implementation of the FileSystem API. A dedicated browser UI does not yet exist for file/quota management. To store data on the user's system, may require your app to request quota. However, for testing, Chrome can be run with the --unlimited-quota-for-files flag. Furthermore, if you're building an app or extension for the Chrome Web Store, the unlimitedStorage manifest file permission can be used in place of requesting quota. Eventually, users will receive a permission dialog to grant, deny, or increase storage for an app.

如果要从 file://调试应用,则可能需要-allow-file-access-from-files 标志.不使用这些标志将导致 SECURITY_ERR QUOTA_EXCEEDED_ERR FileError.

You may need the --allow-file-access-from-files flag if you're debugging your app from file://. Not using these flags will result in a SECURITY_ERR or QUOTA_EXCEEDED_ERR FileError.

这篇关于科尔多瓦:从VS 2017使用--allow-file-access-from-files启动chrome的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆