fix(basic.gblib): Fix in SEND FILE version.
This commit is contained in:
parent
66ea211dd5
commit
3f266f1262
3 changed files with 15 additions and 18 deletions
|
@ -1279,12 +1279,20 @@ export class DialogKeywords {
|
||||||
|
|
||||||
else {
|
else {
|
||||||
|
|
||||||
const ext = mime.extension(Path.extname(filename.localName));
|
const ext = mime.extension(Path.extname(filename));
|
||||||
const buf = Fs.readFileSync(filename);
|
|
||||||
const gbaiName = DialogKeywords.getGBAIPath(min.botId);
|
const gbaiName = DialogKeywords.getGBAIPath(min.botId);
|
||||||
const localName = Path.join('work', gbaiName, 'cache', `tmp${GBAdminService.getRndReadableIdentifier()}.${ext}`);
|
|
||||||
Fs.writeFileSync(localName, buf, { encoding: null });
|
let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min);
|
||||||
url = urlJoin(GBServer.globals.publicAddress, min.botId, 'cache', Path.basename(localName));
|
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));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1087,17 +1087,6 @@ export class KeywordsExpressions {
|
||||||
$3 = $3.replace(/\"/g, '');
|
$3 = $3.replace(/\"/g, '');
|
||||||
let fields = $3.split(',');
|
let fields = $3.split(',');
|
||||||
const table = fields[0].trim();
|
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();
|
fields.shift();
|
||||||
|
|
||||||
const fieldsAsText = fields.join(',');
|
const fieldsAsText = fields.join(',');
|
||||||
|
|
|
@ -589,7 +589,7 @@ export class SystemKeywords {
|
||||||
/**
|
/**
|
||||||
* Retrives a document from the drive, given a path and filename.
|
* 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 res = await client.api(`${baseUrl}/drive/root:/${path}:/children`).get();
|
||||||
|
|
||||||
let documents = res.value.filter(m => {
|
let documents = res.value.filter(m => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue