mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
✨ Add copy-file functionality to GoogleDrive-Node
This commit is contained in:
parent
ffba4d9553
commit
8789e9be3c
|
@ -71,6 +71,11 @@ export class GoogleDrive implements INodeType {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
options: [
|
options: [
|
||||||
|
{
|
||||||
|
name: 'Copy',
|
||||||
|
value: 'copy',
|
||||||
|
description: 'Copy a file',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'Delete',
|
name: 'Delete',
|
||||||
value: 'delete',
|
value: 'delete',
|
||||||
|
@ -128,6 +133,29 @@ export class GoogleDrive implements INodeType {
|
||||||
// file
|
// file
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
|
|
||||||
|
// ----------------------------------
|
||||||
|
// file:copy
|
||||||
|
// ----------------------------------
|
||||||
|
{
|
||||||
|
displayName: 'ID',
|
||||||
|
name: 'fileId',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
required: true,
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
operation: [
|
||||||
|
'copy'
|
||||||
|
],
|
||||||
|
resource: [
|
||||||
|
'file',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
description: 'The ID of the file to copy.',
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
// file/folder:delete
|
// file/folder:delete
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
|
@ -635,6 +663,45 @@ export class GoogleDrive implements INodeType {
|
||||||
default: [],
|
default: [],
|
||||||
description: 'The fields to return.',
|
description: 'The fields to return.',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
displayName: 'File Name',
|
||||||
|
name: 'name',
|
||||||
|
type: 'string',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
'/operation': [
|
||||||
|
'copy'
|
||||||
|
],
|
||||||
|
'/resource': [
|
||||||
|
'file',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
default: '',
|
||||||
|
placeholder: 'invoice_1.pdf',
|
||||||
|
description: 'The name the file should be saved as.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Parents',
|
||||||
|
name: 'parents',
|
||||||
|
type: 'string',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
'/operation': [
|
||||||
|
'copy'
|
||||||
|
],
|
||||||
|
'/resource': [
|
||||||
|
'file',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
typeOptions: {
|
||||||
|
multipleValues: true,
|
||||||
|
},
|
||||||
|
default: [],
|
||||||
|
description: 'The IDs of the parent folders the file should be saved in.',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Spaces',
|
displayName: 'Spaces',
|
||||||
name: 'spaces',
|
name: 'spaces',
|
||||||
|
@ -780,7 +847,31 @@ export class GoogleDrive implements INodeType {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resource === 'file') {
|
if (resource === 'file') {
|
||||||
if (operation === 'download') {
|
if (operation === 'copy') {
|
||||||
|
// ----------------------------------
|
||||||
|
// copy
|
||||||
|
// ----------------------------------
|
||||||
|
|
||||||
|
const fileId = this.getNodeParameter('fileId', i) as string;
|
||||||
|
|
||||||
|
const copyOptions = {
|
||||||
|
fileId,
|
||||||
|
fields: queryFields,
|
||||||
|
requestBody: {} as IDataObject,
|
||||||
|
};
|
||||||
|
|
||||||
|
const optionProperties = ['name', 'parents'];
|
||||||
|
for (const propertyName of optionProperties) {
|
||||||
|
if (options[propertyName] !== undefined) {
|
||||||
|
copyOptions.requestBody[propertyName] = options[propertyName];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await drive.files.copy(copyOptions);
|
||||||
|
|
||||||
|
returnData.push(response.data as IDataObject);
|
||||||
|
|
||||||
|
} else if (operation === 'download') {
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
// download
|
// download
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
|
|
Loading…
Reference in a new issue