Get absolute path to assets folder in PhoneGap

后端 未结 3 846
旧时难觅i
旧时难觅i 2020-12-31 10:05

Is there a way to get the absolute path of an image in phonegap asset folder?

I need the absolute path to attach the image in a mail using EmailComposer plugin.

3条回答
  •  伪装坚强ぢ
    2020-12-31 10:20

    It looks like this is not possible.

    See https://groups.google.com/forum/#!topic/phonegap/Sw2wThOYm8c

    From Simon's response in that thread he states...

    "You can't do what you want to do. The files in the assets directory are not technically on the file system so they are not accessible via the File API. This means calling window. resolveLocalFileSystemURI() will not return you a FileEntry. It is properly returning an error code of 1 which is NOT_FOUND_ERR. "

    You need the absolute path of a file for the email attachments plugin to work. Unfortunately if the file resides in the assets folder, you cannot use cordova's file api to get the absolute path.

    There is a plugin that exists to copy files out of your assets folder and place them onto the sdcard. You can then pass the exact location of this file to the email attachments plugin. Unfortunately it looks like the plugin below is out of date if you are planning on using the newer cordova versions.

    https://github.com/gkcgautam/Asset2SD

提交回复
热议问题