Add storage to web chat

This commit is contained in:
Eudes Inácio
2021-12-16 16:36:39 +01:00
parent 796143d7c4
commit e1b4ce8113
9 changed files with 513 additions and 157 deletions
+27 -2
View File
@@ -12,7 +12,7 @@ import { ToastService } from '../toast.service';
import { Camera, CameraResultType, CameraSource, Photo} from '@capacitor/camera';
import { Filesystem, Directory } from '@capacitor/filesystem';
import { environment } from 'src/environments/environment';
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
import { HttpClient, HttpEventType, HttpHeaders, HttpParams } from '@angular/common/http';
const IMAGE_DIR = 'stored-images';
@@ -39,6 +39,8 @@ export class FileService {
idroom: any;
headers: HttpHeaders;
downloadProgess = 0;
downloadFilename: any;
constructor(
private fileLoaderService: FileLoaderService,
@@ -57,7 +59,7 @@ export class FileService {
alert('OIEE')
//const geturl = environment.apiURL + 'Tasks/DelegateTask';
const geturl = environment.apiURL + 'lakefs/UploadFiles';
const geturl = environment.apiURL + 'ObjectServer/UploadFiles';
let options = {
headers: this.headers
@@ -79,6 +81,28 @@ export class FileService {
return this.http.get<any>(`${geturl}`, options);
}
downloadFile(guid:any) {
let downloadUrl = 'https://equilibrium.dyndns.info/GabineteDigital.Services/V5/api/objectserver/streamfiles?path='+guid;
var name = new Date().getTime();
return this.http.get(downloadUrl, {
responseType: "arraybuffer",
reportProgress: true, observe: 'events'
})
}
_arrayBufferToBase64( buffer ) {
var binary = '';
var bytes = new Uint8Array( buffer );
var len = bytes.byteLength;
for (var i = 0; i < len; i++) {
binary += String.fromCharCode( bytes[ i ] );
}
return window.btoa( binary );
}
async takePicture() {
const capturedImage = await Camera.getPhoto({
quality: 90,
@@ -378,6 +402,7 @@ export class FileService {
"file":{
"type": "application/img",
"guid": guid.path,
"image_url": ""
}
}
}