This commit is contained in:
ivan gomes
2021-12-03 17:27:10 +01:00
parent 40e0aa0d39
commit dc84401716
13 changed files with 165 additions and 113 deletions
+36 -10
View File
@@ -10,11 +10,15 @@ import { SearchList } from 'src/app/models/search-document';
import { ProcessesService } from '../processes.service';
import { ToastService } from '../toast.service';
import { Camera, CameraResultType, CameraSource, Photo} from '@capacitor/camera';
import {
FileSharer} from '@byteowls/capacitor-filesharer';
import { Filesystem, Directory } from '@capacitor/filesystem';
import { Share } from '@capacitor/share';
import { HttpClient } from '@angular/common/http';
const IMAGE_DIR = 'stored-images';
interface LocalFile {
name: string;
path: string;
@@ -45,7 +49,8 @@ export class FileService {
private processesService: ProcessesService,
private toastService: ToastService,
private platform: Platform,
private loadingCtrl: LoadingController
private loadingCtrl: LoadingController,
private http: HttpClient
) { }
async takePicture() {
@@ -230,15 +235,11 @@ export class FileService {
if (image) {
await this.saveImage(image,roomId)
}
/* const response = await fetch(capturedImage.webPath!);
const blob = await response.blob();
this.photos.unshift({
filepath: "soon...",
webviewPath: capturedImage.webPath
}); */
//this.capturedImage = this.capturedImage;
await Share.share({
title: 'Check my image',
url: image.path
})
}
@@ -256,6 +257,13 @@ export class FileService {
if (capturedImage) {
await this.saveImage(capturedImage,roomId)
}
await Share.share({
title: 'Check my image',
url: capturedImage.path
})
/* const response = await fetch(capturedImage.webPath!);
const blob = await response.blob();
@@ -289,6 +297,24 @@ export class FileService {
//loader.remove();
});
*/ }
async shareLocalFile(){
this.http.get('./assets/any.svg', {responseType: 'blob'}).subscribe(res=>{
const reader = new FileReader()
reader.onloadend=()=>{
const result = reader.result as string
const base64Data = result.split(',')[1]
FileSharer.share({
filename:'any.pdf',
base64Data,
contentType: "application/pdf",
})
reader.readAsDataURL(res)
}
})
}
addPictureToChat(roomId) {