diff --git a/packages/basic.gblib/services/DialogKeywords.ts b/packages/basic.gblib/services/DialogKeywords.ts index 7c8acc39..6a819c35 100644 --- a/packages/basic.gblib/services/DialogKeywords.ts +++ b/packages/basic.gblib/services/DialogKeywords.ts @@ -1278,13 +1278,21 @@ export class DialogKeywords { // .gbdrive direct sending. else { - - const ext = mime.extension(Path.extname(filename.localName)); - const buf = Fs.readFileSync(filename); + + const ext = mime.extension(Path.extname(filename)); const gbaiName = DialogKeywords.getGBAIPath(min.botId); - const localName = Path.join('work', gbaiName, 'cache', `tmp${GBAdminService.getRndReadableIdentifier()}.${ext}`); - Fs.writeFileSync(localName, buf, { encoding: null }); - url = urlJoin(GBServer.globals.publicAddress, min.botId, 'cache', Path.basename(localName)); + + let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min); + let path = '/' + urlJoin(gbaiName, `${min.botId}.gbdrive`); + const sys = new SystemKeywords(); + let template = await sys.internalGetDocument(client, baseUrl, path, filename); + let url = template['@microsoft.graph.downloadUrl']; + const res = await fetch(url); + let buf: any = Buffer.from(await res.arrayBuffer()); + let localName1 = Path.join('work', gbaiName, 'cache', `tmp${GBAdminService.getRndReadableIdentifier()}.docx`); + Fs.writeFileSync(localName1, buf, { encoding: null }); + + url = urlJoin(GBServer.globals.publicAddress, min.botId, 'cache', Path.basename(localName1)); } diff --git a/packages/basic.gblib/services/KeywordsExpressions.ts b/packages/basic.gblib/services/KeywordsExpressions.ts index 10bdaf49..4360225b 100644 --- a/packages/basic.gblib/services/KeywordsExpressions.ts +++ b/packages/basic.gblib/services/KeywordsExpressions.ts @@ -1087,17 +1087,6 @@ export class KeywordsExpressions { $3 = $3.replace(/\"/g, ''); let fields = $3.split(','); const table = fields[0].trim(); - - if (table.indexOf('.xlsx') !== -1) - { // Same as SAVE above. - $3 = $3.replace(/\'/g, ''); - $3 = $3.replace(/\"/g, ''); - $4 = $4.substr(2); - return `await sys.save({pid: pid, file: "${$3}", args: [${$4}]})`; - - } - - fields.shift(); const fieldsAsText = fields.join(','); diff --git a/packages/basic.gblib/services/SystemKeywords.ts b/packages/basic.gblib/services/SystemKeywords.ts index 8947e6ad..a17f359c 100644 --- a/packages/basic.gblib/services/SystemKeywords.ts +++ b/packages/basic.gblib/services/SystemKeywords.ts @@ -589,7 +589,7 @@ export class SystemKeywords { /** * Retrives a document from the drive, given a path and filename. */ - private async internalGetDocument(client: any, baseUrl: any, path: string, file: string) { + public async internalGetDocument(client: any, baseUrl: any, path: string, file: string) { let res = await client.api(`${baseUrl}/drive/root:/${path}:/children`).get(); let documents = res.value.filter(m => {