forked from activepieces/activepieces
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(file-helper): add create file from text action
- Loading branch information
1 parent
362638b
commit c03e858
Showing
3 changed files
with
24 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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": "*" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
packages/pieces/community/file-helper/src/lib/actions/create-file.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }; | ||
}, | ||
}); |