mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
reviewed
This commit is contained in:
@@ -129,21 +129,21 @@ export class NewPublicationPage implements OnInit {
|
|||||||
// toast.present();
|
// toast.present();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
async selectImage() {
|
// async selectImage() {
|
||||||
const image = await Camera.getPhoto({
|
// const image = await Camera.getPhoto({
|
||||||
quality: 90,
|
// quality: 90,
|
||||||
allowEditing: false,
|
// allowEditing: false,
|
||||||
resultType: CameraResultType.Uri,
|
// resultType: CameraResultType.Uri,
|
||||||
source: CameraSource.Camera // Camera, Photos or Prompt!
|
// source: CameraSource.Camera // Camera, Photos or Prompt!
|
||||||
});
|
// });
|
||||||
|
|
||||||
if (image) {
|
// if (image) {
|
||||||
this.saveImage(image)
|
// this.saveImage(image)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Create a new file from a capture image
|
// Create a new file from a capture image
|
||||||
async saveImage(photo: Photo) {
|
/* async saveImage(photo: Photo) {
|
||||||
const base64Data = await this.readAsBase64(photo);
|
const base64Data = await this.readAsBase64(photo);
|
||||||
|
|
||||||
const fileName = new Date().getTime() + '.jpeg';
|
const fileName = new Date().getTime() + '.jpeg';
|
||||||
@@ -156,25 +156,25 @@ async saveImage(photo: Photo) {
|
|||||||
// Reload the file list
|
// Reload the file list
|
||||||
// Improve by only loading for the new image and unshifting array!
|
// Improve by only loading for the new image and unshifting array!
|
||||||
this.loadFiles();
|
this.loadFiles();
|
||||||
}
|
} */
|
||||||
|
|
||||||
// https://ionicframework.com/docs/angular/your-first-app/3-saving-photos
|
// https://ionicframework.com/docs/angular/your-first-app/3-saving-photos
|
||||||
private async readAsBase64(photo: Photo) {
|
// private async readAsBase64(photo: Photo) {
|
||||||
if (this.platform.is('hybrid')) {
|
// if (this.platform.is('hybrid')) {
|
||||||
const file = await Filesystem.readFile({
|
// const file = await Filesystem.readFile({
|
||||||
path: photo.path
|
// path: photo.path
|
||||||
});
|
// });
|
||||||
|
|
||||||
return file.data;
|
// return file.data;
|
||||||
}
|
// }
|
||||||
else {
|
// else {
|
||||||
// Fetch the photo, read as a blob, then convert to base64 format
|
// // Fetch the photo, read as a blob, then convert to base64 format
|
||||||
const response = await fetch(photo.webPath);
|
// const response = await fetch(photo.webPath);
|
||||||
const blob = await response.blob();
|
// const blob = await response.blob();
|
||||||
|
|
||||||
return await this.convertBlobToBase64(blob) as string;
|
// return await this.convertBlobToBase64(blob) as string;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Helper function
|
// Helper function
|
||||||
convertBlobToBase64 = (blob: Blob) => new Promise((resolve, reject) => {
|
convertBlobToBase64 = (blob: Blob) => new Promise((resolve, reject) => {
|
||||||
@@ -506,49 +506,49 @@ private async savePicture(photo: Photo) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// async selectImage() {
|
async selectImage() {
|
||||||
// const image = await Camera.getPhoto({
|
const image = await Camera.getPhoto({
|
||||||
// quality: 90,
|
quality: 90,
|
||||||
// allowEditing: false,
|
allowEditing: false,
|
||||||
// resultType: CameraResultType.Uri,
|
resultType: CameraResultType.Uri,
|
||||||
// source: CameraSource.Photos // Camera, Photos or Prompt!
|
source: CameraSource.Photos // Camera, Photos or Prompt!
|
||||||
// });
|
});
|
||||||
|
|
||||||
// if (image) {
|
if (image) {
|
||||||
// this.saveImage(image)
|
this.saveImage(image)
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// // Create a new file from a capture image
|
// // Create a new file from a capture image
|
||||||
// async saveImage(photo: Photo) {
|
async saveImage(photo: Photo) {
|
||||||
// const base64Data = await this.readAsBase64(photo);
|
const base64Data = await this.readAsBase64(photo);
|
||||||
|
|
||||||
// const fileName = new Date().getTime() + '.jpeg';
|
const fileName = new Date().getTime() + '.jpeg';
|
||||||
// const savedFile = await Filesystem.writeFile({
|
const savedFile = await Filesystem.writeFile({
|
||||||
// path: `${IMAGE_DIR}/${fileName}`,
|
path: `${IMAGE_DIR}/${fileName}`,
|
||||||
// data: base64Data,
|
data: base64Data,
|
||||||
// directory: Directory.Data
|
directory: Directory.Data
|
||||||
// });
|
});
|
||||||
|
|
||||||
// this.loadFiles();
|
this.loadFiles();
|
||||||
// }
|
}
|
||||||
|
|
||||||
// private async readAsBase64(photo: Photo) {
|
private async readAsBase64(photo: Photo) {
|
||||||
// if (this.platform.is('hybrid')) {
|
if (this.platform.is('hybrid')) {
|
||||||
// const file = await Filesystem.readFile({
|
const file = await Filesystem.readFile({
|
||||||
// path: photo.path
|
path: photo.path
|
||||||
// });
|
});
|
||||||
|
|
||||||
// return file.data;
|
return file.data;
|
||||||
// }
|
}
|
||||||
// else {
|
else {
|
||||||
// // Fetch the photo, read as a blob, then convert to base64 format
|
// Fetch the photo, read as a blob, then convert to base64 format
|
||||||
// const response = await fetch(photo.webPath);
|
const response = await fetch(photo.webPath);
|
||||||
// const blob = await response.blob();
|
const blob = await response.blob();
|
||||||
|
|
||||||
// return await this.convertBlobToBase64(blob) as string;
|
return await this.convertBlobToBase64(blob) as string;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
async loadFiles() {
|
async loadFiles() {
|
||||||
this.images = [];
|
this.images = [];
|
||||||
|
|||||||
Reference in New Issue
Block a user