mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
🔀 Merge branch 'onedrive-creatt push origin mastere-folder-hierarchy'
This commit is contained in:
commit
3898b86cc9
|
@ -56,6 +56,7 @@ export const folderFields = [
|
||||||
name: 'name',
|
name: 'name',
|
||||||
required: true,
|
required: true,
|
||||||
type: 'string',
|
type: 'string',
|
||||||
|
placeholder: '/Pictures/2021',
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
operation: [
|
operation: [
|
||||||
|
@ -67,7 +68,7 @@ export const folderFields = [
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
default: '',
|
default: '',
|
||||||
description: `Folder's name`,
|
description: 'The name or path of the folder',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Options',
|
displayName: 'Options',
|
||||||
|
|
|
@ -97,7 +97,7 @@ export class MicrosoftOneDrive implements INodeType {
|
||||||
body.name = additionalFields.name as string;
|
body.name = additionalFields.name as string;
|
||||||
}
|
}
|
||||||
responseData = await microsoftApiRequest.call(this, 'POST', `/drive/items/${fileId}/copy`, body, {}, undefined, {}, { json: true, resolveWithFullResponse: true });
|
responseData = await microsoftApiRequest.call(this, 'POST', `/drive/items/${fileId}/copy`, body, {}, undefined, {}, { json: true, resolveWithFullResponse: true });
|
||||||
responseData = { location : responseData.headers.location };
|
responseData = { location: responseData.headers.location };
|
||||||
returnData.push(responseData as IDataObject);
|
returnData.push(responseData as IDataObject);
|
||||||
}
|
}
|
||||||
//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
|
||||||
|
@ -193,7 +193,7 @@ export class MicrosoftOneDrive implements INodeType {
|
||||||
const binaryData = (items[i].binary as IBinaryKeyData)[binaryPropertyName];
|
const binaryData = (items[i].binary as IBinaryKeyData)[binaryPropertyName];
|
||||||
const body = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
|
const body = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
|
||||||
|
|
||||||
responseData = await microsoftApiRequest.call(this, 'PUT', `/drive/items/${parentId}:/${fileName || binaryData.fileName}:/content`, body, {}, undefined, { 'Content-Type': binaryData.mimeType, 'Content-length': body.length }, {} );
|
responseData = await microsoftApiRequest.call(this, 'PUT', `/drive/items/${parentId}:/${fileName || binaryData.fileName}:/content`, body, {}, undefined, { 'Content-Type': binaryData.mimeType, 'Content-length': body.length }, {});
|
||||||
|
|
||||||
returnData.push(JSON.parse(responseData) as IDataObject);
|
returnData.push(JSON.parse(responseData) as IDataObject);
|
||||||
} else {
|
} else {
|
||||||
|
@ -201,7 +201,7 @@ export class MicrosoftOneDrive implements INodeType {
|
||||||
if (fileName === '') {
|
if (fileName === '') {
|
||||||
throw new NodeOperationError(this.getNode(), 'File name must be set!');
|
throw new NodeOperationError(this.getNode(), 'File name must be set!');
|
||||||
}
|
}
|
||||||
responseData = await microsoftApiRequest.call(this, 'PUT', `/drive/items/${parentId}:/${fileName}:/content`, body , {}, undefined, { 'Content-Type': 'text/plain' } );
|
responseData = await microsoftApiRequest.call(this, 'PUT', `/drive/items/${parentId}:/${fileName}:/content`, body, {}, undefined, { 'Content-Type': 'text/plain' });
|
||||||
returnData.push(responseData as IDataObject);
|
returnData.push(responseData as IDataObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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 (const name of names) {
|
||||||
folder: {},
|
const 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