mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
download file on web fixed
This commit is contained in:
@@ -1034,11 +1034,12 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
|
||||
}
|
||||
|
||||
downloadFileFromBrowser(fileName: string, data: any): void {
|
||||
const linkSource = data;
|
||||
const downloadLink = document.createElement("a");
|
||||
downloadLink.href = linkSource;
|
||||
downloadLink.download = fileName;
|
||||
downloadLink.click();
|
||||
const link = document.createElement("a")
|
||||
link.href = `data:${data.type}';base64,${data.image_url}`;
|
||||
link.download = fileName
|
||||
link.click()
|
||||
|
||||
link.remove()
|
||||
}
|
||||
|
||||
b64toBlob(b64Data, contentType) {
|
||||
@@ -1120,7 +1121,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
|
||||
});
|
||||
modal.present();
|
||||
} else {
|
||||
this.downloadFileFromBrowser(msg.attachments[0].title, msg.attachments[0].attachmentsUrl)
|
||||
this.downloadFileFromBrowser(msg.attachments[0].title, msg.attachments[0])
|
||||
}
|
||||
} else {
|
||||
this.openFile(msg.attachments.image_url, msg.attachments[0].title, msg.file.type);
|
||||
|
||||
@@ -35,6 +35,7 @@ import { ChatMessageDebuggingPage } from 'src/app/shared/popover/chat-message-de
|
||||
import { PermissionService } from 'src/app/services/permission.service';
|
||||
import { FileValidatorService } from "src/app/services/file/file-validator.service"
|
||||
import { ChangeDetectorRef } from '@angular/core';
|
||||
import { saveAs } from 'file-saver';
|
||||
|
||||
|
||||
const IMAGE_DIR = 'stored-images';
|
||||
@@ -141,7 +142,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
this.ChatSystemService.openRoom(this.roomId)
|
||||
|
||||
this.ChatSystemService.getDmRoom(this.roomId)
|
||||
this.ChatSystemService.getDmRoom(this.roomId).setChangeDetector(()=> {
|
||||
this.ChatSystemService.getDmRoom(this.roomId).setChangeDetector(() => {
|
||||
this.changeDetector()
|
||||
})
|
||||
|
||||
@@ -712,7 +713,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
source: CameraSource.Camera
|
||||
});
|
||||
|
||||
console.log('FILE CHAT',file)
|
||||
console.log('FILE CHAT', file)
|
||||
|
||||
const imageBase64 = 'data:image/jpeg;base64,' + file.base64String
|
||||
const blob = this.dataURItoBlob(imageBase64)
|
||||
@@ -886,7 +887,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
/* console.log('add file', fileBase64) */
|
||||
|
||||
} else {
|
||||
console.log('encode data' ,encodedData)
|
||||
console.log('encode data', encodedData)
|
||||
blob = this.fileService.base64toBlob(encodedData, file.type)
|
||||
|
||||
fileBase64 = await this._getBase64(file)
|
||||
@@ -1093,13 +1094,13 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
}
|
||||
|
||||
downloadFileFromBrowser(fileName: string, data: any): void {
|
||||
const linkSource = data;
|
||||
console.log('data in', data)
|
||||
const downloadLink = document.createElement("a");
|
||||
downloadLink.href = linkSource;
|
||||
console.log('downloadLink.href',downloadLink.href)
|
||||
downloadLink.download = fileName;
|
||||
downloadLink.click();
|
||||
|
||||
const link = document.createElement("a")
|
||||
link.href = `data:${data.type}';base64,${data.image_url}`;
|
||||
link.download = fileName
|
||||
link.click()
|
||||
|
||||
link.remove()
|
||||
}
|
||||
|
||||
viewDocument(file: any, url?: string) {
|
||||
@@ -1167,7 +1168,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
});
|
||||
modal.present();
|
||||
} else {
|
||||
this.downloadFileFromBrowser(msg.attachments[0].title, msg.attachments[0].attachmentsUrl,)
|
||||
this.downloadFileFromBrowser(msg.attachments[0].title, msg.attachments[0],)
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user