🔀 Merge branch 'master' into arpadgabor-feat/monaco

This commit is contained in:
Jan Oberhauser 2021-12-22 07:46:16 +01:00
commit 27f696ad27

View file

@ -239,7 +239,7 @@ export class GoogleDrive implements INodeType {
// file:download // file:download
// ---------------------------------- // ----------------------------------
{ {
displayName: 'File Id', displayName: 'File ID',
name: 'fileId', name: 'fileId',
type: 'string', type: 'string',
default: '', default: '',
@ -291,6 +291,124 @@ export class GoogleDrive implements INodeType {
}, },
}, },
options: [ options: [
{
displayName: 'Google File Conversion',
name: 'googleFileConversion',
type: 'fixedCollection',
typeOptions: {
multipleValues: false,
},
default: {},
placeholder: 'Add Conversion',
options: [
{
displayName: 'Conversion',
name: 'conversion',
values: [
{
displayName: 'Google Docs',
name: 'docsToFormat',
type: 'options',
options: [
{
name: 'To MS Word',
value: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
},
{
name: 'To PDF',
value: 'application/pdf',
},
{
name: 'To OpenOffice Doc',
value: 'application/vnd.oasis.opendocument.text',
},
{
name: 'To HTML',
value: 'text/html',
},
{
name: 'To Rich Text',
value: 'application/rtf',
},
],
default: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
description: 'Format used to export when downloading Google Docs files',
},
{
displayName: 'Google Drawings',
name: 'drawingsToFormat',
type: 'options',
options: [
{
name: 'To JPEG',
value: 'image/jpeg',
},
{
name: 'To PNG',
value: 'image/png',
},
{
name: 'To SVG',
value: 'image/svg+xml',
},
{
name: 'To PDF',
value: 'application/pdf',
},
],
default: 'image/jpeg',
description: 'Format used to export when downloading Google Drawings files',
},
{
displayName: 'Google Slides',
name: 'slidesToFormat',
type: 'options',
options: [
{
name: 'To MS PowerPoint',
value: 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
},
{
name: 'To PDF',
value: 'application/pdf',
},
{
name: 'To OpenOffice Presentation',
value: 'application/vnd.oasis.opendocument.presentation',
},
{
name: 'To Plain Text',
value: 'text/plain',
},
],
default: 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
description: 'Format used to export when downloading Google Slides files',
},
{
displayName: 'Google Sheets',
name: 'sheetsToFormat',
type: 'options',
options: [
{
name: 'To MS Excel',
value: 'application/x-vnd.oasis.opendocument.spreadsheet',
},
{
name: 'To PDF',
value: 'application/pdf',
},
{
name: 'To CSV',
value: 'text/csv',
},
],
default: 'application/x-vnd.oasis.opendocument.spreadsheet',
description: 'Format used to export when downloading Google Spreadsheets files',
},
],
},
],
},
{ {
displayName: 'File Name', displayName: 'File Name',
name: 'fileName', name: 'fileName',
@ -2136,7 +2254,26 @@ export class GoogleDrive implements INodeType {
json: false, json: false,
}; };
const response = await googleApiRequest.call(this, 'GET', `/drive/v3/files/${fileId}`, {}, { alt: 'media' }, undefined, requestOptions); const file = await googleApiRequest.call(this, 'GET', `/drive/v3/files/${fileId}`, {}, { fields: 'mimeType' });
let response;
if (file.mimeType.includes('vnd.google-apps')) {
const parameterKey = 'options.googleFileConversion.conversion';
const type = file.mimeType.split('.')[2];
let mime;
if (type === 'document') {
mime = this.getNodeParameter(`${parameterKey}.docsToFormat`, i, 'application/vnd.openxmlformats-officedocument.wordprocessingml.document') as string;
} else if (type === 'presentation') {
mime = this.getNodeParameter(`${parameterKey}.slidesToFormat`, i, 'application/vnd.openxmlformats-officedocument.presentationml.presentation') as string;
} else if (type === 'spreadsheet') {
mime = this.getNodeParameter(`${parameterKey}.sheetsToFormat`, i, 'application/x-vnd.oasis.opendocument.spreadsheet') as string;
} else {
mime = this.getNodeParameter(`${parameterKey}.drawingsToFormat`, i, 'image/jpeg') as string;
}
response = await googleApiRequest.call(this, 'GET', `/drive/v3/files/${fileId}/export`, {}, { mimeType: mime }, undefined, requestOptions);
} else {
response = await googleApiRequest.call(this, 'GET', `/drive/v3/files/${fileId}`, {}, { alt: 'media' }, undefined, requestOptions);
}
let mimeType: string | undefined; let mimeType: string | undefined;
let fileName: string | undefined = undefined; let fileName: string | undefined = undefined;