Accessing ExternalStoragePublicDirectory in Google Chrome ARC app

前端 未结 1 1134
春和景丽
春和景丽 2021-02-03 14:57

We have a feature in our app which can save file to ExternalStoragePublicDirectory. Below is the directory path we are using. Environment.getExternalStoragePublicDirectory(Envir

1条回答
  •  生来不讨喜
    2021-02-03 15:41

    Under ARC, your external storage files are being read and written to the HTML5 filesystem. Under Chrome app (yours included) gets its own filesystem.

    You can view this filesystem with Chrome (desktop or Chromebook) using some experimental developer tools. You have to enable them and then restart the browser. Here is how:

    • Visit "chrome://flags" in your browser.
    • Search for "Enable Developer Tools experiments", and click the "Enable" link.
    • A prompt to restart your browser should have appeared. Go ahead and click it to restart your browser.
    • Go ahead and launch your app. It needs to be running so that you can browse the filesystem.
    • Next visit the "chrome://inspect/#apps" page in your browser, and find your app in the list. Click the "inspect" link to bring up the inspector window.
    • Click the gear icon in the upper right of the window.
    • Click the "Experiments" tab listed on the left side of the popup. This is only visible if you enabled the experimental features at all.
    • Click the "Filesystem Inspection" checkbox to enable the filesystem viewer.
    • Finish up by closing the options page with the "x" at the top left.

    Now you can view your app's filesystem.

    • From the inspector window for your app, click the "Resources" tab along the top.
    • You should see a "FileSystem" option appear in the list on the left side. Click it to expand it.
    • Click the "persistent -chrome extension:" subpanel.
    • You should be able to then navigate to the download directory by expanding the view that appears. I believe for downloads you want "/storage/sdcard/Download".

    Selecting the directory will display basic metadata on all the files in the directory. Selecting the file might display it if it is supported. Or you might just get a "Binary File" message if not.

    If you want to actually manipulate the data beyond that, you will need to connect with the browser with the Android adb command/shell, and you should be able to "adb pull" the file. See https://developer.chrome.com/apps/getstarted_arc#bestpractices to get going on that.

    You can also add {"enableExternalDirectory": true} to your application's metadata. Enabling this option means that ARC will prompt you for the directory to use for for the external directory, and you can pick a real directory on your system to use. But if you already download a file prior to enabling this feature, you will have to download it again.

    0 讨论(0)
提交回复
热议问题