我正在使用cordova文件传输来上传图片和文档。这适用于从设备中选择图像或文档,但是当我从谷歌驱动器中选择图像或文档时,我正在使用空文件。我的代码是
doc_capture(page, mediatype, id?) {
const options: CameraOptions = {
quality: 75,
destinationType: this.camera.DestinationType.FILE_URI,
targetWidth: 300,
targetHeight: 300,
correctOrientation: true,
sourceType: this.camera.PictureSourceType.PHOTOLIBRARY,
mediaType: mediatype == 'PICTURE' ? 0 : 2
}
return this.camera.getPicture(options).then((fileUri) => {
let filePath;
if (mediatype == 'PICTURE' && this.plt.is('android')) {
filePath = fileUri.substr(0, fileUri.lastIndexOf('?'));
} else {
filePath = fileUri;
}
return this.file_upload(filePath, page, id)
}, err => {
return Promise.reject('');
});
}