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,59 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const fileUploadDescription: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Input Data Field Name',
|
||||
name: 'binaryPropertyName',
|
||||
type: 'string',
|
||||
default: 'data',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['upload'],
|
||||
resource: ['file'],
|
||||
},
|
||||
},
|
||||
required: true,
|
||||
description:
|
||||
'The name of the input field containing the binary file data to be uploaded. Supported file types: PNG, JPEG.',
|
||||
},
|
||||
{
|
||||
displayName: 'Category Name or ID',
|
||||
name: 'categoryId',
|
||||
type: 'options',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getCompanyFileCategories',
|
||||
},
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['upload'],
|
||||
resource: ['file'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Options',
|
||||
name: 'options',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['upload'],
|
||||
resource: ['file'],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Share with Employee',
|
||||
name: 'share',
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
description: 'Whether this file is shared or not',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,40 @@
|
||||
import type { IDataObject, IExecuteFunctions } from 'n8n-workflow';
|
||||
|
||||
import { apiRequest } from '../../../transport';
|
||||
|
||||
export async function upload(this: IExecuteFunctions, index: number) {
|
||||
let body: IDataObject = {};
|
||||
const requestMethod = 'POST';
|
||||
|
||||
const category = this.getNodeParameter('categoryId', index) as string;
|
||||
const share = this.getNodeParameter('options.share', index, true) as boolean;
|
||||
|
||||
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', index);
|
||||
const { fileName, mimeType } = this.helpers.assertBinaryData(index, binaryPropertyName);
|
||||
const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(index, binaryPropertyName);
|
||||
|
||||
body = {
|
||||
json: false,
|
||||
formData: {
|
||||
file: {
|
||||
value: binaryDataBuffer,
|
||||
options: {
|
||||
filename: fileName,
|
||||
contentType: mimeType,
|
||||
},
|
||||
},
|
||||
fileName,
|
||||
category,
|
||||
},
|
||||
resolveWithFullResponse: true,
|
||||
};
|
||||
|
||||
if (body.formData) {
|
||||
Object.assign(body.formData, share ? { share: 'yes' } : { share: 'no' });
|
||||
}
|
||||
|
||||
//endpoint
|
||||
const endpoint = 'files';
|
||||
const { headers } = await apiRequest.call(this, requestMethod, endpoint, {}, {}, body);
|
||||
return this.helpers.returnJsonArray({ fileId: headers.location.split('/').pop() });
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { fileUploadDescription as description } from './description';
|
||||
import { upload as execute } from './execute';
|
||||
|
||||
export { description, execute };
|
||||
Reference in New Issue
Block a user