我需要使用离子本机文件打开器打开jpg图像
我从这个问题中使用了mime类型 (how to open (doc, ppt, xlsx, pdf, jpg ,png) file using ionic native file opener)
除了jpg以外,其他所有工具都工作正常。 我试图将mime更改为“ image / pjpeg”或“ x-citrix-jpeg” (在这里找到:Is the MIME type 'image/jpg' the same as 'image/jpeg'?)
我尝试打开文件的代码:
openFile(file: any) {
const fileExtn = file.filePath.split('.').reverse()[0];
const fileMIMEType = this.getMIMEtype(fileExtn);
//alert('ext: ' + fileExtn + ' mime: ' + fileMIMEType);
this.fileOpener.open(file.filePath, fileMIMEType)
.catch(e => alert('Error opening file:\n' + e));
}
我尝试选择mime的代码:
getMIMEtype(extn) {
const ext = extn.toLowerCase();
const MIMETypes = {
.......
'jpg': 'image/jpeg',
'jpeg': 'image/jpeg',
'bmp': 'image/bmp',
'png': 'image/png',
.......
};
return MIMETypes[ext];
}
警报给出以下错误: [对象对象]