bug send file chat

This commit is contained in:
Eudes Inácio
2022-02-10 19:47:16 +01:00
parent d32cbabac6
commit ae7e14d062
5 changed files with 38 additions and 10 deletions
+17 -5
View File
@@ -33,6 +33,7 @@ import { SearchPage } from 'src/app/pages/search/search.page';
import { ProcessesService } from 'src/app/services/processes.service';
import { FileToBase64Service } from 'src/app/services/file/file-to-base64.service';
import { Camera, CameraResultType, CameraSource } from '@capacitor/camera';
import { DocumentViewer, DocumentViewerOptions} from '@ionic-native/document-viewer';
const IMAGE_DIR = 'stored-images';
@Component({
@@ -600,22 +601,26 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
const roomId = this.roomId
const file: any = await this.fileService.getFileFromDevice(types);
console.log('Add image', file)
const imageData = await this.fileToBase64Service.convert(file)
console.log('Add file', file)
/* const imageData = await this.fileToBase64Service.convert(file).then((filee) => {
console.log('Add file', filee)
}) */
const blob = new Blob([file],{type: file.type})
console.log('Add file', blob)
const formData = new FormData();
formData.append("blobFile", file);
formData.append("blobFile", blob);
this.wsChatMethodsService.getDmRoom(roomId).send({
file: {
"type": "application/img",
"type": file.type,
"guid": '',
},
attachments: [{
"title": file.name ,
"name": file.name ,
// "text": "description",
"image_url": imageData, // rocketchat
"image_url": file, // rocketchat
"title_link_download": false,
}],
temporaryData: formData
@@ -747,6 +752,13 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
}
pdfPreviwe() {
const options: DocumentViewerOptions = {
title: 'My App'
};
DocumentViewer.viewDocument
}
async openPreview(msg) {
if (msg.file.image_url === null || msg.file.image_url === '' ) {