first commit
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,122 @@
|
||||
import {
|
||||
updateDisplayOptions,
|
||||
type IExecuteSingleFunctions,
|
||||
type IN8nHttpFullResponse,
|
||||
type INodeExecutionData,
|
||||
type INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { microsoftSharePointApiRequest } from '../../transport';
|
||||
import {
|
||||
fileRLC,
|
||||
folderRLC,
|
||||
siteRLC,
|
||||
untilFolderSelected,
|
||||
untilSiteSelected,
|
||||
} from '../common.descriptions';
|
||||
|
||||
const properties: INodeProperties[] = [
|
||||
{
|
||||
...siteRLC,
|
||||
description: 'Select the site to retrieve folders from',
|
||||
},
|
||||
{
|
||||
...folderRLC,
|
||||
description: 'Select the folder to update the file in',
|
||||
displayOptions: {
|
||||
hide: {
|
||||
...untilSiteSelected,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
...fileRLC,
|
||||
description: 'Select the file to update',
|
||||
displayOptions: {
|
||||
hide: {
|
||||
...untilSiteSelected,
|
||||
...untilFolderSelected,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Updated File Name',
|
||||
name: 'fileName',
|
||||
default: '',
|
||||
description: 'If not specified, the original file name will be used',
|
||||
placeholder: 'e.g. My New File',
|
||||
routing: {
|
||||
send: {
|
||||
property: 'name',
|
||||
type: 'body',
|
||||
value: '={{ $value }}',
|
||||
},
|
||||
},
|
||||
type: 'string',
|
||||
},
|
||||
{
|
||||
displayName: 'Change File Content',
|
||||
name: 'changeFileContent',
|
||||
default: false,
|
||||
description: 'Whether to update the file contents',
|
||||
placeholder: 'e.g. My New File',
|
||||
required: true,
|
||||
type: 'boolean',
|
||||
},
|
||||
{
|
||||
displayName: 'Updated File Contents',
|
||||
name: 'fileContents',
|
||||
default: '',
|
||||
description:
|
||||
'Find the name of input field containing the binary data to update the file with in the Input panel on the left, in the Binary tab',
|
||||
displayOptions: {
|
||||
show: {
|
||||
changeFileContent: [true],
|
||||
},
|
||||
},
|
||||
hint: 'The name of the input field containing the binary file data to update the file with',
|
||||
placeholder: 'data',
|
||||
required: true,
|
||||
routing: {
|
||||
output: {
|
||||
postReceive: [
|
||||
async function (
|
||||
this: IExecuteSingleFunctions,
|
||||
items: INodeExecutionData[],
|
||||
_response: IN8nHttpFullResponse,
|
||||
): Promise<INodeExecutionData[]> {
|
||||
for (const item of items) {
|
||||
const site = this.getNodeParameter('site', undefined, {
|
||||
extractValue: true,
|
||||
}) as string;
|
||||
const file = this.getNodeParameter('file', undefined, {
|
||||
extractValue: true,
|
||||
}) as string;
|
||||
const binaryProperty = this.getNodeParameter('fileContents') as string;
|
||||
this.helpers.assertBinaryData(binaryProperty);
|
||||
const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(binaryProperty);
|
||||
const response = await microsoftSharePointApiRequest.call(
|
||||
this,
|
||||
'PUT',
|
||||
`/sites/${site}/drive/items/${file}/content`,
|
||||
binaryDataBuffer,
|
||||
);
|
||||
item.json = response;
|
||||
}
|
||||
return items;
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
type: 'string',
|
||||
},
|
||||
];
|
||||
|
||||
const displayOptions = {
|
||||
show: {
|
||||
resource: ['file'],
|
||||
operation: ['update'],
|
||||
},
|
||||
};
|
||||
|
||||
export const description = updateDisplayOptions(displayOptions, properties);
|
||||
Reference in New Issue
Block a user