Chrome应用程式的档案沙箱位于哪里? [英] Where is the file sandbox for a Chrome app?

查看:176
本文介绍了Chrome应用程式的档案沙箱位于哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个具有处理文件功能的chrome应用程序。我需要将这些文件复制到应用程序,我相信将其存储在应用程序的沙箱中。

I'm developing a chrome app with the capability to handle files. I need to copy these files to the app, which I believe stores it in the app's sandbox.

但是这些文件在哪里,就像在我的磁盘上?

But where are these files, like on my disk?

这里是我访问文件系统的位置:

Here's where I get access to the filesystem:

fs = null

oneGig = Math.pow 2, 30 # 1GB
window.webkitRequestFileSystem window.PERSISTENT, oneGig,
  (_fs) -> # on fs init
    fs = _fs
    console.log fs.root.fullPath #=> "/" obviously not right

  (e) -> # on fs error
    console.log e

后面跟随这段代码来实际写入文件。

Followed by this code to actually write the files.

fs.root.getFile songObj.md5, create: true, (fileEntry) ->
  fileEntry.createWriter (fileWriter) ->
    fileWriter.onwriteend = (e) ->
      console.log 'Song file saved!', fileEntry, e

      # Where the hell on disk is my file now?

    fileWriter.onerror    = (e) ->
      console.log 'fileWriter.onerror', e

    fileWriter.write songObj.blob

  , (e) -> console.log 'fileEntry.createWriter error', e
, (e) -> console.log 'fs.root.getFile error', e

文件处理,并希望能够轻松地检查发生了什么,以及如果必要的话清理。而我似乎找不到任何地方的文档,它说文件去。这种情况尤其令人沮丧,因为我在几天后回到应用程序后,文件就消失了。

I've had some bugs in my file handling and want to be able to easily inspect what is going on, as well as clean things up if necessary. And I can't seem find anywhere in the docs that it says files go. And this especially frustrating since I'm have files just vanish after coming back to the app a few days later.

推荐答案

进入不容易检查的沙箱。您可能想改用新的chrome.fileSystem chooseEntry函数( http://developer.chrome.com) /apps/fileSystem.html )与目录选项和retainEntry访问写入您的计算机上的正常目录,以便您可以看到文件,并使它们不被清除时,您清除浏览器缓存等。

They go into a "sandbox" which isn't easy to inspect. You might want to instead use the new chrome.fileSystem chooseEntry function (http://developer.chrome.com/apps/fileSystem.html) with the "directory" option and also "retainEntry" to get access to write to a normal directory on your computer, so that you can see the files and have them not be cleared out when you clear your browser cache, etc.

这篇关于Chrome应用程式的档案沙箱位于哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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