mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 04:04:06 -08:00
onedrive folders hierarchy creation support
This commit is contained in:
parent
8618415772
commit
49fbea7551
|
@ -67,7 +67,7 @@ export const folderFields = [
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
default: '',
|
default: '',
|
||||||
description: `Folder's name`,
|
description: `Folder's name, or a folders slash (/) separated hierarchy`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Options',
|
displayName: 'Options',
|
||||||
|
|
|
@ -209,17 +209,24 @@ export class MicrosoftOneDrive implements INodeType {
|
||||||
if (resource === 'folder') {
|
if (resource === 'folder') {
|
||||||
//https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_post_children?view=odsp-graph-online
|
//https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_post_children?view=odsp-graph-online
|
||||||
if (operation === 'create') {
|
if (operation === 'create') {
|
||||||
const name = this.getNodeParameter('name', i) as string;
|
const names = (this.getNodeParameter('name', i) as string).split("/").filter( s => s.trim() != "" );
|
||||||
const options = this.getNodeParameter('options', i) as IDataObject;
|
const options = this.getNodeParameter('options', i) as IDataObject;
|
||||||
const body: IDataObject = {
|
let parentFolderId = options.parentFolderId ? options.parentFolderId : null;
|
||||||
name,
|
for( let name of names ) {
|
||||||
folder: {},
|
let body: IDataObject = {
|
||||||
};
|
name,
|
||||||
let endpoint = '/drive/root/children';
|
folder: {},
|
||||||
if (options.parentFolderId) {
|
};
|
||||||
endpoint = `/drive/items/${options.parentFolderId}/children`;
|
let endpoint = '/drive/root/children';
|
||||||
|
if (parentFolderId) {
|
||||||
|
endpoint = `/drive/items/${parentFolderId}/children`;
|
||||||
|
}
|
||||||
|
responseData = await microsoftApiRequest.call(this, 'POST', endpoint, body);
|
||||||
|
if( !responseData.id ) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
parentFolderId = responseData.id;
|
||||||
}
|
}
|
||||||
responseData = await microsoftApiRequest.call(this, 'POST', endpoint, body);
|
|
||||||
returnData.push(responseData);
|
returnData.push(responseData);
|
||||||
}
|
}
|
||||||
//https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_delete?view=odsp-graph-online
|
//https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_delete?view=odsp-graph-online
|
||||||
|
|
Loading…
Reference in a new issue