Ionic 3 native

时间:2017-08-19 11:25:56

标签: angular ionic2 ionic-native

调用promise<MediaFile[]>时,MediaCapture插件返回的this.mediaCapture.captureImage()返回了捕获图像的错误fullPath

MediaFile
end:0
fullPath:"file:///storage/emulated/0/Pictures/1503140105277.jpg"
lastModified:null
lastModifiedDate:1503140121000
localURL:"cdvfile://localhost/sdcard/Pictures/1503140105277.jpg"
name:"1503140105277.jpg"
size:4261137
start:0
type:"image/jpeg"
__proto__:File
length:1

我无法从此fullPath访问该文件,但是当我使用FileChooser插件并通过此代码获取文件URI时:

this.fileChooser.open()
        .then(uri => {
          console.log('from file chooser: ',uri);
          this.filePath.resolveNativePath(uri)
          .then(filePath => {
            console.log('from filepath: ',filePath);
            this.navCtrl.push('NewPostPage', {
              mediaFile : filePath
            })
          })
          .catch(err => console.log(err));

由此返回的文件路径是:

from file chooser:  content://com.android.providers.media.documents/document/image%3A13988 
from filepath:  file:///storage/emulated/0/DCIM/Camera/IMG_20170819_155509.jpg

您可以看到mediaCapture插件返回的承诺和FileChooser插件的文件路径不同:

MediaCapture: "file:///storage/emulated/0/Pictures/1503140105277.jpg"
FileChooser: "file:///storage/emulated/0/DCIM/Camera/IMG_20170819_155509.jpg"

我很容易从FileChooser返回的字符串中获取图像。但我不能使用fileChooser插件告诉我该怎么做,或者我哪里出错了。

0 个答案:

没有答案