Skip to content

Commit a781302

Browse files
committed
add: zoho_catalyst
1 parent 43a3eed commit a781302

File tree

8 files changed

+26
-33
lines changed

8 files changed

+26
-33
lines changed

components/zoho_catalyst/actions/detect-objects-in-image/detect-objects-in-image.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default defineAction({
66
key: "zoho_catalyst-detect-objects-in-image",
77
name: "Detect Objects in Image",
88
description: "Detect or recognize objects in an image. [See the documentation](https://catalyst.zoho.com/help/api/zia/or.html)",
9-
version: "0.0.1",
9+
version: "0.1.0",
1010
type: "action",
1111
props: {
1212
app,
@@ -28,14 +28,12 @@ export default defineAction({
2828
imagePath, projectId,
2929
} = this;
3030

31-
const data = getImageFormData(imagePath);
31+
const data = await getImageFormData(imagePath);
3232

3333
const response = await this.app.detectObjectsInImage({
3434
$,
3535
projectId,
36-
headers: {
37-
...data.getHeaders(),
38-
},
36+
headers: data.getHeaders(),
3937
data,
4038
});
4139

components/zoho_catalyst/actions/extract-text-from-image/extract-text-from-image.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default defineAction({
66
key: "zoho_catalyst-extract-text-from-image",
77
name: "Extract Text from Image",
88
description: "Extract text from an image. [See the documentation](https://catalyst.zoho.com/help/api/zia/ocr.html)",
9-
version: "0.0.1",
9+
version: "0.1.0",
1010
type: "action",
1111
props: {
1212
app,
@@ -28,14 +28,12 @@ export default defineAction({
2828
imagePath, projectId,
2929
} = this;
3030

31-
const data = getImageFormData(imagePath);
31+
const data = await getImageFormData(imagePath);
3232

3333
const response = await this.app.extractTextFromImage({
3434
$,
3535
projectId,
36-
headers: {
37-
...data.getHeaders(),
38-
},
36+
headers: data.getHeaders(),
3937
data,
4038
});
4139

components/zoho_catalyst/actions/perform-face-detection-and-analysis/perform-face-detection-and-analysis.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default defineAction({
77
key: "zoho_catalyst-perform-face-detection-and-analysis",
88
name: "Perform Face Detection and Analysis",
99
description: "Perform face detection and analysis on an image. [See the documentation](https://catalyst.zoho.com/help/api/zia/face-analytics.html)",
10-
version: "0.0.1",
10+
version: "0.1.0",
1111
type: "action",
1212
props: {
1313
app,
@@ -58,7 +58,7 @@ export default defineAction({
5858
imagePath, projectId,
5959
} = this;
6060

61-
const data = getImageFormData(imagePath);
61+
const data = await getImageFormData(imagePath);
6262
for (const prop of [
6363
"mode",
6464
"emotion",
@@ -73,9 +73,7 @@ export default defineAction({
7373
const response = await this.app.performImageFaceDetection({
7474
$,
7575
projectId,
76-
headers: {
77-
...data.getHeaders(),
78-
},
76+
headers: data.getHeaders(),
7977
data,
8078
});
8179

components/zoho_catalyst/actions/perform-image-moderation/perform-image-moderation.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default defineAction({
77
key: "zoho_catalyst-perform-image-moderation",
88
name: "Perform Image Moderation",
99
description: "Perform image moderation on an image. [See the documentation](https://catalyst.zoho.com/help/api/zia/image-moderation.html)",
10-
version: "0.0.1",
10+
version: "0.1.0",
1111
type: "action",
1212
props: {
1313
app,
@@ -37,15 +37,13 @@ export default defineAction({
3737
imagePath, projectId, mode,
3838
} = this;
3939

40-
const data = getImageFormData(imagePath);
40+
const data = await getImageFormData(imagePath);
4141
if (mode) data.append("mode", mode);
4242

4343
const response = await this.app.performImageModeration({
4444
$,
4545
projectId,
46-
headers: {
47-
...data.getHeaders(),
48-
},
46+
headers: data.getHeaders(),
4947
data,
5048
});
5149

components/zoho_catalyst/app/zoho_catalyst.app.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ export default defineApp({
2626
},
2727
imagePath: {
2828
type: "string",
29-
label: "Image Path",
30-
description:
31-
"A file path in the `/tmp` directory. [See the documentation on working with files.](https://pipedream.com/docs/code/nodejs/working-with-files/)",
29+
label: "Image Path or URL",
30+
description: "The image to upload. Provide either a file URL or a path to a file in the `/tmp` directory (for example, `/tmp/myFile.png`)",
3231
},
3332
mode: {
3433
type: "string",
Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
import fs from "fs";
1+
import { getFileStreamAndMetadata } from "@pipedream/platform";
22
import FormData from "form-data";
33

4-
export function getImageFormData(imagePath: string) {
5-
const content = fs.createReadStream(imagePath.startsWith("/tmp")
6-
? imagePath
7-
: `/tmp/${imagePath}`.replace(/\/\//g, "/"));
4+
export async function getImageFormData(imagePath: string) {
5+
const { stream, metadata } = await getFileStreamAndMetadata(imagePath);
86

97
const data = new FormData();
10-
data.append("image", content);
8+
data.append("image", stream, {
9+
filename: metadata.name,
10+
contentType: metadata.contentType,
11+
knownLength: metadata.size,
12+
});
1113
return data;
1214
}

components/zoho_catalyst/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/zoho_catalyst",
3-
"version": "0.1.0",
3+
"version": "0.2.0",
44
"description": "Pipedream Zoho Catalyst Components",
55
"main": "dist/app/zoho_catalyst.app.mjs",
66
"keywords": [
@@ -14,7 +14,7 @@
1414
"access": "public"
1515
},
1616
"dependencies": {
17-
"@pipedream/platform": "^1.5.1",
17+
"@pipedream/platform": "^3.1.0",
1818
"@pipedream/types": "^0.1.6",
1919
"form-data": "^4.0.0"
2020
}

pnpm-lock.yaml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)