Small change to #2305

This commit is contained in:
ricardo 2021-10-17 09:28:29 -04:00
parent 431f58a5ee
commit c888b0512a

View file

@ -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,11 +209,11 @@ 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 names = (this.getNodeParameter('name', i) as string).split("/").filter( s => s.trim() != "" ); 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;
let parentFolderId = options.parentFolderId ? options.parentFolderId : null; let parentFolderId = options.parentFolderId ? options.parentFolderId : null;
for( let name of names ) { for (const name of names) {
let body: IDataObject = { const body: IDataObject = {
name, name,
folder: {}, folder: {},
}; };
@ -222,7 +222,7 @@ export class MicrosoftOneDrive implements INodeType {
endpoint = `/drive/items/${parentFolderId}/children`; endpoint = `/drive/items/${parentFolderId}/children`;
} }
responseData = await microsoftApiRequest.call(this, 'POST', endpoint, body); responseData = await microsoftApiRequest.call(this, 'POST', endpoint, body);
if( !responseData.id ) { if (!responseData.id) {
break; break;
} }
parentFolderId = responseData.id; parentFolderId = responseData.id;