2023-01-27 03:22:44 -08:00
import type { INodeProperties } from 'n8n-workflow' ;
2020-03-08 15:22:33 -07:00
2021-12-03 00:44:16 -08:00
export const fileOperations : INodeProperties [ ] = [
2020-03-08 15:22:33 -07:00
{
displayName : 'Operation' ,
name : 'operation' ,
type : 'options' ,
2022-05-20 14:47:24 -07:00
noDataExpression : true ,
2020-03-08 15:22:33 -07:00
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'file' ] ,
2020-03-08 15:22:33 -07:00
} ,
} ,
options : [
{
name : 'Get' ,
value : 'get' ,
description : 'Get a file info' ,
2022-07-10 13:50:51 -07:00
action : 'Get a file' ,
2020-03-08 15:22:33 -07:00
} ,
{
2022-09-07 07:51:14 -07:00
name : 'Get Many' ,
2020-03-08 15:22:33 -07:00
value : 'getAll' ,
2022-05-06 14:01:25 -07:00
description : 'Get & filters team files' ,
2022-09-08 08:10:13 -07:00
action : 'Get many files' ,
2020-03-08 15:22:33 -07:00
} ,
{
name : 'Upload' ,
value : 'upload' ,
2022-05-06 14:01:25 -07:00
description : 'Create or upload an existing file' ,
2022-07-10 13:50:51 -07:00
action : 'Upload a file' ,
2020-03-08 15:22:33 -07:00
} ,
] ,
default : 'upload' ,
} ,
2021-12-03 00:44:16 -08:00
] ;
2020-03-08 15:22:33 -07:00
2021-12-03 00:44:16 -08:00
export const fileFields : INodeProperties [ ] = [
2020-12-13 01:47:52 -08:00
/* -------------------------------------------------------------------------- */
/* file:upload */
/* -------------------------------------------------------------------------- */
2020-03-08 15:22:33 -07:00
{
2024-01-03 03:08:16 -08:00
displayName : 'Binary File' ,
2020-03-08 15:22:33 -07:00
name : 'binaryData' ,
type : 'boolean' ,
default : false ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
operation : [ 'upload' ] ,
resource : [ 'file' ] ,
2020-03-08 15:22:33 -07:00
} ,
} ,
2022-06-20 07:54:01 -07:00
description : 'Whether the data to upload should be taken from binary field' ,
2020-03-08 15:22:33 -07:00
} ,
{
displayName : 'File Content' ,
name : 'fileContent' ,
type : 'string' ,
default : '' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
operation : [ 'upload' ] ,
resource : [ 'file' ] ,
binaryData : [ false ] ,
2020-03-08 15:22:33 -07:00
} ,
} ,
placeholder : '' ,
2022-05-06 14:01:25 -07:00
description : 'The text content of the file to upload' ,
2020-03-08 15:22:33 -07:00
} ,
{
2024-01-03 03:08:16 -08:00
displayName : 'Input Binary Field' ,
2020-03-08 15:22:33 -07:00
name : 'binaryPropertyName' ,
type : 'string' ,
default : 'data' ,
required : true ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
operation : [ 'upload' ] ,
resource : [ 'file' ] ,
binaryData : [ true ] ,
2020-03-08 15:22:33 -07:00
} ,
} ,
placeholder : '' ,
2024-01-03 03:08:16 -08:00
hint : 'The name of the input binary field containing the file to be uploaded' ,
2020-03-08 15:22:33 -07:00
} ,
{
displayName : 'Options' ,
name : 'options' ,
type : 'collection' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
operation : [ 'upload' ] ,
resource : [ 'file' ] ,
2020-03-08 15:22:33 -07:00
} ,
} ,
default : { } ,
description : 'Other options to set' ,
placeholder : 'Add options' ,
options : [
{
2022-06-20 07:54:01 -07:00
displayName : 'Channel Names or IDs' ,
2020-03-08 15:22:33 -07:00
name : 'channelIds' ,
type : 'multiOptions' ,
typeOptions : {
loadOptionsMethod : 'getChannels' ,
} ,
default : [ ] ,
2022-08-17 08:50:24 -07:00
description :
'The channels to send the file to. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.' ,
2020-03-08 15:22:33 -07:00
} ,
{
displayName : 'File Name' ,
name : 'fileName' ,
type : 'string' ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'Filename of file' ,
2020-03-08 15:22:33 -07:00
} ,
{
displayName : 'Initial Comment' ,
name : 'initialComment' ,
type : 'string' ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'The message text introducing the file in specified channels' ,
2020-03-08 15:22:33 -07:00
} ,
{
displayName : 'Thread TS' ,
name : 'threadTs' ,
type : 'string' ,
default : '' ,
2022-08-17 08:50:24 -07:00
description :
"Provide another message's ts value to upload this file as a reply. Never use a reply's ts value; use its parent instead." ,
2020-03-08 15:22:33 -07:00
} ,
{
displayName : 'Title' ,
name : 'title' ,
type : 'string' ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'Title of file' ,
2020-03-08 15:22:33 -07:00
} ,
] ,
} ,
2020-12-13 01:47:52 -08:00
/* ----------------------------------------------------------------------- */
/* file:getAll */
/* ----------------------------------------------------------------------- */
2020-03-08 15:22:33 -07:00
{
displayName : 'Return All' ,
name : 'returnAll' ,
type : 'boolean' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'file' ] ,
operation : [ 'getAll' ] ,
2020-03-08 15:22:33 -07:00
} ,
} ,
default : false ,
2022-05-06 14:01:25 -07:00
description : 'Whether to return all results or only up to a given limit' ,
2020-03-08 15:22:33 -07:00
} ,
{
displayName : 'Limit' ,
name : 'limit' ,
type : 'number' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'file' ] ,
operation : [ 'getAll' ] ,
returnAll : [ false ] ,
2020-03-08 15:22:33 -07:00
} ,
} ,
typeOptions : {
minValue : 1 ,
maxValue : 100 ,
} ,
default : 50 ,
2022-05-06 14:01:25 -07:00
description : 'Max number of results to return' ,
2020-03-08 15:22:33 -07:00
} ,
{
displayName : 'Filters' ,
name : 'filters' ,
type : 'collection' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
operation : [ 'getAll' ] ,
resource : [ 'file' ] ,
2020-03-08 15:22:33 -07:00
} ,
} ,
default : { } ,
placeholder : 'Add Field' ,
options : [
{
2022-06-03 10:23:49 -07:00
displayName : 'Channel Name or ID' ,
2020-03-08 15:22:33 -07:00
name : 'channelId' ,
type : 'options' ,
default : '' ,
typeOptions : {
loadOptionsMethod : 'getChannels' ,
} ,
2022-08-17 08:50:24 -07:00
description :
'Channel containing the file to be listed. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.' ,
2020-03-08 15:22:33 -07:00
} ,
{
displayName : 'Show Files Hidden By Limit' ,
name : 'showFilesHidden' ,
type : 'boolean' ,
default : false ,
2022-08-17 08:50:24 -07:00
description :
'Whether to show truncated file info for files hidden due to being too old, and the team who owns the file being over the file limit' ,
2020-03-08 15:22:33 -07:00
} ,
{
2021-01-23 03:17:38 -08:00
displayName : 'Timestamp From' ,
2020-03-08 15:22:33 -07:00
name : 'tsFrom' ,
type : 'string' ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'Filter files created after this timestamp (inclusive)' ,
2020-03-08 15:22:33 -07:00
} ,
{
2021-01-23 03:17:38 -08:00
displayName : 'Timestamp To' ,
2020-03-08 15:22:33 -07:00
name : 'tsTo' ,
type : 'string' ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'Filter files created before this timestamp (inclusive)' ,
2020-03-08 15:22:33 -07:00
} ,
{
displayName : 'Types' ,
name : 'types' ,
type : 'multiOptions' ,
options : [
{
name : 'All' ,
value : 'all' ,
} ,
{
2020-12-13 01:47:52 -08:00
name : 'Google Docs' ,
value : 'gdocs' ,
2020-03-08 15:22:33 -07:00
} ,
{
name : 'Images' ,
value : 'images' ,
} ,
2022-06-20 07:54:01 -07:00
{
name : 'PDFs' ,
value : 'pdfs' ,
} ,
2020-03-08 15:22:33 -07:00
{
2020-12-13 01:47:52 -08:00
name : 'Snippets' ,
value : 'snippets' ,
2020-03-08 15:22:33 -07:00
} ,
{
2020-12-13 01:47:52 -08:00
name : 'Spaces' ,
value : 'spaces' ,
2020-03-08 15:22:33 -07:00
} ,
2020-12-13 01:47:52 -08:00
{
2022-06-03 10:23:49 -07:00
// eslint-disable-next-line n8n-nodes-base/node-param-display-name-miscased
name : 'zips' ,
2020-12-13 01:47:52 -08:00
value : 'zips' ,
} ,
2020-03-08 15:22:33 -07:00
] ,
default : [ 'all' ] ,
description : 'Filter files by type' ,
} ,
{
2022-06-03 10:23:49 -07:00
displayName : 'User Name or ID' ,
2020-03-08 15:22:33 -07:00
name : 'userId' ,
type : 'options' ,
default : '' ,
typeOptions : {
loadOptionsMethod : 'getUsers' ,
} ,
2022-08-17 08:50:24 -07:00
description :
'Filter files created by a single user. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.' ,
2020-03-08 15:22:33 -07:00
} ,
] ,
} ,
2020-12-13 01:47:52 -08:00
/* ----------------------------------------------------------------------- */
/* file:get */
/* ----------------------------------------------------------------------- */
2020-03-08 15:22:33 -07:00
{
displayName : 'File ID' ,
name : 'fileId' ,
type : 'string' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'file' ] ,
operation : [ 'get' ] ,
2020-03-08 15:22:33 -07:00
} ,
} ,
default : '' ,
} ,
2021-12-03 00:44:16 -08:00
] ;