Skip to content

Commit

Permalink
feat(file-helper): add create file from text action
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamSelene committed Mar 21, 2024
1 parent 362638b commit c03e858
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/pieces/community/file-helper/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "@activepieces/piece-file-helper",
"version": "0.0.6",
"version": "0.0.7",
"dependencies": {
"@activepieces/pieces-framework": "*",
"tslib": "2.6.2",
"@activepieces/shared": "*"
}
}
}
5 changes: 3 additions & 2 deletions packages/pieces/community/file-helper/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { createPiece, PieceAuth } from '@activepieces/pieces-framework';
import { PieceCategory } from '@activepieces/shared';
import { readFileAction } from './lib/actions/read-file';
import { createFile } from './lib/actions/create-file';

export const filesHelper = createPiece({
displayName: 'Files Helper',
Expand All @@ -9,7 +10,7 @@ export const filesHelper = createPiece({
minimumSupportedRelease: '0.9.0',
logoUrl: 'https://cdn.activepieces.com/pieces/file-piece.svg',
categories: [PieceCategory.CORE],
authors: ["kishanprmr","MoShizzle","abuaboud"],
actions: [readFileAction],
authors: ['kishanprmr', 'MoShizzle', 'abuaboud'],
actions: [readFileAction, createFile],
triggers: [],
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { createAction, Property } from '@activepieces/pieces-framework';

export const createFile = createAction({
// auth: check https://www.activepieces.com/docs/developers/piece-reference/authentication,
name: 'createFile',
displayName: 'Create file',
description: 'Create file from UTF-8 content',
props: {
content: Property.LongText({ displayName: 'Content', required: true }),
fileName: Property.ShortText({ displayName: 'File name', required: true }),
},
async run({ propsValue, files }) {
const fileUrl = await files.write({
fileName: propsValue.fileName,
data: Buffer.from(propsValue.content, 'utf-8'),
});
return { fileName: propsValue.fileName, url: fileUrl };
},
});

0 comments on commit c03e858

Please sign in to comment.