Skip to content

Commit 724480c

Browse files
authored
Configure file stash sync for Zoho CRM components (#17267)
Add dir props to the Zoho CRM Download Attachment and Upload Attachment actions to indicate that a stash ID should be passed when running these actions via the Connect API. This allows files written to the ephemeral /tmp directory in one action to be read by another, separately executed action since both can sync /tmp with the same File Stash directory. The prop is optional in the Zoho CRM Upload Attachment action since the file reference used as input can be a file URL rather than local file path. If a file URL is used, then the /tmp <-> File Stash sync is not needed and a stash ID is not required. The prop is also optional in the Zoho CRM Download Attachment action since the file content is returned directly from the `run` method of the action, in addition to being written to a file. So the action can be used in Connect without persisting the file for later use.
1 parent 6a0fe3f commit 724480c

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

components/zoho_crm/actions/download-attachment/download-attachment.mjs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "zoho_crm-download-attachment",
66
name: "Download Attachment",
77
description: "Downloads an attachment file from Zoho CRM, saves it in the temporary file system and exports the file path for use in a future step.",
8-
version: "0.2.1",
8+
version: "0.2.2",
99
type: "action",
1010
props: {
1111
zohoCrm,
@@ -34,6 +34,16 @@ export default {
3434
}),
3535
],
3636
},
37+
// This prop indicates that the otherwise ephemeral /tmp directory is automatically synced to a
38+
// remote directory (if configured for the execution context), making files written by this
39+
// action accessible for future executions. Only files located in STASH_DIR or, for legacy
40+
// action support, whose /tmp file paths are explicitly returned by `run` will be synced.
41+
syncDir: {
42+
type: "dir",
43+
accessMode: "write",
44+
sync: true,
45+
optional: true,
46+
},
3747
},
3848
async run({ $ }) {
3949
const file = await this.zohoCrm.downloadAttachment(
@@ -43,7 +53,7 @@ export default {
4353
$,
4454
);
4555

46-
const filePath = "/tmp/" + this.attachmentId;
56+
const filePath = (process.env.STASH_DIR || "/tmp") + "/" + this.attachmentId;
4757
fs.writeFileSync(filePath, file);
4858

4959
$.export("$summary", "Successfully downloaded attachment");

components/zoho_crm/actions/upload-attachment/upload-attachment.mjs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default {
66
key: "zoho_crm-upload-attachment",
77
name: "Upload Attachment",
88
description: "Uploads an attachment file to Zoho CRM from a URL or file path. [See the documentation](https://www.zoho.com/crm/developer/docs/api/v3/upload-attachment.html)",
9-
version: "0.1.0",
9+
version: "0.1.1",
1010
type: "action",
1111
props: {
1212
zohoCrm,
@@ -30,6 +30,15 @@ export default {
3030
label: "File Path or URL",
3131
description: "The file to upload. Provide either a file URL or a path to a file in the `/tmp` directory (for example, `/tmp/myFile.txt`)",
3232
},
33+
// This prop indicates that a remote directory (if configured for the execution context) is
34+
// automatically synced to the /tmp directory before the action runs, making files in that
35+
// directory accessible for use in this action via the file system.
36+
syncDir: {
37+
type: "dir",
38+
accessMode: "read",
39+
sync: true,
40+
optional: true,
41+
},
3342
},
3443
async run({ $ }) {
3544
const data = new FormData();

components/zoho_crm/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/zoho_crm",
3-
"version": "0.6.0",
3+
"version": "0.6.1",
44
"description": "Pipedream Zoho CRM Components",
55
"main": "zoho_crm.app.mjs",
66
"keywords": [

0 commit comments

Comments
 (0)