From 4368fe447bd71c0d0ab3d04db11f656a0303c6ca Mon Sep 17 00:00:00 2001 From: Rodrigo Rodriguez Date: Tue, 23 Nov 2021 12:04:07 -0300 Subject: [PATCH] new(basic.gblib): HEAR in Teams will get pictures into URL. --- packages/basic.gblib/services/SystemKeywords.ts | 10 ++++++---- packages/core.gbapp/services/GBMinService.ts | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/basic.gblib/services/SystemKeywords.ts b/packages/basic.gblib/services/SystemKeywords.ts index 59f71c0e..30abeb6c 100644 --- a/packages/basic.gblib/services/SystemKeywords.ts +++ b/packages/basic.gblib/services/SystemKeywords.ts @@ -952,13 +952,11 @@ export class SystemKeywords { * @example user = get "http://server/users/1" * */ - public async getByHttp(url: string, headers: any, username: string, ps: string, qs: any) { + public async getByHttp(url: string, headers: any, username: string, ps: string, qs: any, streaming = false) { let options = { - encoding: "binary", url: url, headers: headers - }; if (username) { options['auth'] = { @@ -969,13 +967,17 @@ export class SystemKeywords { if (qs) { options['qs'] = qs; } + if (streaming) { + options['responseType'] = 'stream'; + options['encoding'] = null; + } const isAO = (val) => { return val instanceof Array || val instanceof Object ? true : false; } let result = await request.get(options); - if (isAO(result)) { + if (isAO(result) && !streaming) { GBLog.info(`[GET]: ${url} : ${result}`); return JSON.parse(result); } diff --git a/packages/core.gbapp/services/GBMinService.ts b/packages/core.gbapp/services/GBMinService.ts index 61a8fddc..8517785b 100644 --- a/packages/core.gbapp/services/GBMinService.ts +++ b/packages/core.gbapp/services/GBMinService.ts @@ -883,7 +883,7 @@ export class GBMinService { const botToken = await credentials.getToken(); const headers = { Authorization: `Bearer ${botToken}` }; const t = new SystemKeywords(null, null, null); - const data = await t.getByHttp(file.contentUrl, headers, null, null, null); + const data = await t.getByHttp(file.contentUrl, headers, null, null, null, true); const folder = `work/${min.instance.botId}.gbai/cache`; const filename =`${GBAdminService.generateUuid()}.png`;