我正在尝试拍照(离子4)并将此图像作为电子邮件附件发送。因此,目的是拍摄照片,将其保存,然后将保存的图像作为电子邮件附件发送。
我尝试遵循从此站点获得的示例:https://devdactic.com/ionic-4-image-upload-storage/
takePicture () {
this.camera.getPicture(this.options).then((imageData) => {
// imageData is either a base64 encoded string or a file URI
// If it's base64 (DATA_URL):
this.filePath.resolveNativePath(imageData)
.then(filePath => {
// I am lost a this point.
let correctPath = filePath.substr(0, filePath.lastIndexOf('/') + 1);
let currentName = imageData.substring(imageData.lastIndexOf('/') + 1, imageData.lastIndexOf('?'));
this.copyFileToLocalDir(correctPath, currentName, this.createFileName());
this.sendMail(currentName);
});
//let base64Image = 'data:image/jpeg;base64,' + imageData;
}, (err) => {
// Handle error
});
}
答案 0 :(得分:0)
您可以添加CameraOptions。要将图像保存到画廊中
这样做:
const options: CameraOptions = {
quality: 100,
destinationType: this.camera.DestinationType.FILE_URI,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE,
saveToPhotoAlbum: true
}
并使用图库中的图片发送电子邮件