local file access on Google-Chrome-ARC?

こ雲淡風輕ζ 提交于 2019-12-22 00:16:33

问题


Is there any way to implement local file access on ARC? As i understand Chrome is sandboxed, so access would be hard, but it seems that the defined android data directory could have a specific folder used for file access?


回答1:


Yes, application on ARC is sandboxed and unable to access to local file system.

However, you can access to the file on your local file system by starting Activity with specific Intent: ACTION_GET_CONTENT for reading file and ACTION_SEND for saving file.

e.g. If you would like to open image file from your local file system,

private static int REQUEST_CODE = 5;

private void requestImageFile() {
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.setType("image/*");
    startActivityForResult(intent, REQUEST_CODE);
}

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == Activity.RESULT_OK && requestCode == REQUEST_CODE) {
        ImageView imgView = new ImageView(this);
        imgView.setImageURI(data.getData());
        setContentView(imgView);
    }
}



回答2:


ARC app may have access to OS Filesystem (via browser file chooser), but will not be able to modify them, i.e. ARC will first copy these items to a different location and feed the app with the copy instead of the original file.

Further read :

https://sslab.gtisc.gatech.edu/2014/arc-security.html



来源:https://stackoverflow.com/questions/29425408/local-file-access-on-google-chrome-arc

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