0

我正在尝试使用该函数检索content://Google Drive 提供的 URI的本地路径。window.resolveLocalFileSystemURL

这是传入的意图对象:

{
  "action": "android.intent.action.SEND",
  "extras": {
    "android.intent.extra.STREAM": "content://com.google.android.apps.docs.storage.legacy/enc%3DfhNPFErrgrEv9o4Q0EfWItmhwQRdSI8diNatIJQGsbDn8UOC%0A"
  },
  "clipItems": [
    {
      "uri": "content://com.google.android.apps.docs.storage.legacy/enc%3DfhNPFErrgrEv9o4Q0EfWItmhwQRdSI8diNatIJQGsbDn8UOC%0A",
      "type": "image/jpeg",
      "extension": "jpg"
    }
  ],
  "type": "image/jpeg",
  "flags": 453509121,
  "component": "ComponentInfo{io.cozy.drive.mobile/io.cozy.drive.mobile.MainActivity}"
}

window.resolveLocalFileSystemUrl返回

{
  "isFile": true,
  "isDirectory": false,
  "name": "enc=fhNPFErrgrEv9o4Q0EfWItmhwQRdSI8diNatIJQGsbDn8UOC\n",
  "fullPath": "/com.google.android.apps.docs.storage.legacy/enc=fhNPFErrgrEv9o4Q0EfWItmhwQRdSI8diNatIJQGsbDn8UOC\n",
  "filesystem": "<FileSystem: content>",
  "nativeURL": "content://com.google.android.apps.docs.storage.legacy/enc%3DfhNPFErrgrEv9o4Q0EfWItmhwQRdSI8diNatIJQGsbDn8UOC%0A"
}

正如cordova-plugin-file 的文档中DirectoryEntry所解释的那样,我可以检索 blob 和基础文件:

{
  "name": "content",
  "localURL": "cdvfile://localhost/content/com.google.android.apps.docs.storage.legacy/enc%3DfhNPFErrgrEv9o4Q0EfWItmhwQRdSI8diNatIJQGsbDn8UOC%0A",
  "type": "image/jpeg",
  "lastModified": 1524043045078,
  "lastModifiedDate": 1524043045078,
  "size": 1597052,
  "start": 0,
  "end": 1597052
}

我确定文件名已编码,enc=fhNPFErrgrEv9o4Q0EfWItmhwQRdSI8diNatIJQGsbDn8UOC但我无法对其进行解码。


由 Dropbox 中的意图创建的完全相同的对象:

意图对象:

{
  "action": "android.intent.action.SEND",
  "extras": {
    "android.intent.extra.STREAM": "file:///storage/emulated/0/Android/data/com.dropbox.android/files/u702227782/scratch/IMG_20180116_124017_dropbox.jpg"
  },
  "clipItems": [
    {
      "uri": "file:///storage/emulated/0/Android/data/com.dropbox.android/files/u702227782/scratch/IMG_20180116_124017_dropbox.jpg"
    }
  ],
  "type": "image/jpeg",
  "flags": 272629763,
  "component": "ComponentInfo{io.cozy.drive.mobile/io.cozy.drive.mobile.MainActivity}"
}

目录入口对象:

{
  "isFile": true,
  "isDirectory": false,
  "name": "IMG_20180116_124017_dropbox.jpg",
  "fullPath": "/Android/data/com.dropbox.android/files/u702227782/scratch/IMG_20180116_124017_dropbox.jpg",
  "filesystem": "<FileSystem: sdcard>",
  "nativeURL": "file:///storage/emulated/0/Android/data/com.dropbox.android/files/u702227782/scratch/IMG_20180116_124017_dropbox.jpg"
}

blob/文件对象:

{
  "name": "IMG_20180116_124017_dropbox.jpg",
  "localURL": "cdvfile://localhost/sdcard/Android/data/com.dropbox.android/files/u702227782/scratch/IMG_20180116_124017_dropbox.jpg",
  "type": "image/jpeg",
  "lastModified": 1524043057000,
  "lastModifiedDate": 1524043057000,
  "size": 1597052,
  "start": 0,
  "end": 1597052
}
4

1 回答 1

0

我将cordova-plugin-filepath更新为v1.3.0,它就像一个魅力!

于 2018-04-18T10:43:47.553 回答