问题
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