Skip to content

Commit a4b09fb

Browse files
authored
File URL and Path Improvements (#17117)
* updates to use getFileStream * pnpm-lock.yaml * versions * jira package version * remove extra twitter app file * updates * updates * updates * versions * updates * pnpm-lock.yaml * pnpm-lock.yaml * versions * pnpm-lock.yaml * updates * versions * updates * update gh action * pnpm-lock.yaml * pnpm-lock.yaml
1 parent a37360e commit a4b09fb

File tree

102 files changed

+843
-742
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+843
-742
lines changed

.github/workflows/pull-request-checks.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ jobs:
9696
format: 'csv'
9797
# NOTE: These steps are kept in this workflow to avoid re-rerunning the rest of the lint job
9898
# in the Components Checks workflow
99+
- name: Build TypeScript Components
100+
run: pnpm build
99101
- name: Check component keys
100102
run: node scripts/findBadKeys.js ${{ steps.changed_files.outputs.added_modified }} ${{ steps.changed_files.outputs.renamed }}
101103
- name: Check component app prop

components/api4ai/actions/alcohol-label-recognition/alcohol-label-recognition.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
name: "Alcohol Label Recognition",
66
description: "Accurately identifies alcohol labels using advanced intelligent technologies. Powered by API4AI.",
77
key: "api4ai-alcohol-label-recognition",
8-
version: "0.0.1",
8+
version: "0.0.2",
99
type: "action",
1010
props: {
1111
app,

components/api4ai/actions/background-removal/background-removal.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default {
88
description:
99
"Automatically and quickly remove image background with high accuracy. Powered by API4AI.",
1010
key: "api4ai-background-removal",
11-
version: "0.0.1",
11+
version: "0.0.2",
1212
type: "action",
1313
props: {
1414
app,

components/api4ai/actions/brand-recognition/brand-recognition.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
name: "Brand Recognition",
66
description: "The service processes input image and responds with a list of found brand logos. Powered by API4AI.",
77
key: "api4ai-brand-recognition",
8-
version: "0.0.1",
8+
version: "0.0.2",
99
type: "action",
1010
props: {
1111
app,

components/api4ai/actions/car-image-background-removal/car-image-background-removal.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default {
88
description:
99
"Remove Background for car images. Powered by API4AI.",
1010
key: "api4ai-car-image-background-removal",
11-
version: "0.0.1",
11+
version: "0.0.2",
1212
type: "action",
1313
props: {
1414
app,

components/api4ai/actions/furniture-and-household-item-recognition/furniture-and-household-item-recognition.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
name: "Furniture & Household Item Recognition",
66
description: "This API provides identification of furniture & household items with advanced intelligent detection, categorization, and counting technologies. Powered by API4AI.",
77
key: "api4ai-furniture-and-household-item-recognition",
8-
version: "0.0.1",
8+
version: "0.0.2",
99
type: "action",
1010
props: {
1111
app,

components/api4ai/actions/image-anonymization/image-anonymization.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
name: "Image Anonymization",
88
description: "Performs actual image anonymization. Powered by API4AI.",
99
key: "api4ai-image-anonymization",
10-
version: "0.0.1",
10+
version: "0.0.2",
1111
type: "action",
1212
props: {
1313
app,

components/api4ai/actions/nsfw-image-recognition/nsfw-image-recognition.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default {
66
description:
77
"Content moderation solution for NSFW (Not Safe For Work) sexual images identification. Powered by API4AI.",
88
key: "api4ai-nsfw-image-recognition",
9-
version: "0.0.1",
9+
version: "0.0.2",
1010
type: "action",
1111
props: {
1212
app,

components/api4ai/api4ai.app.mjs

Lines changed: 13 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { axios } from "@pipedream/platform";
1+
import {
2+
axios, getFileStreamAndMetadata,
3+
} from "@pipedream/platform";
24
import FormData from "form-data";
3-
import fs from "node:fs";
45

56
export default {
67
type: "app",
@@ -9,63 +10,22 @@ export default {
910
image: {
1011
type: "string",
1112
label: "Image",
12-
description: "Input image. Various types are accepted:\n * a **path** to a file\n * a **URL** to a file\n * a file's content encoded as a **base64** string\n * a file's content as a **Buffer** encoded in JSON\n * a file's content as an **Array** of bytes",
13+
description: "Input image. Provide either a file URL or a path to a file in the /tmp directory (for example, /tmp/myFile.pdf).",
1314
},
1415
},
1516
methods: {
16-
// this.$auth contains connected account data
17-
authKeys() {
18-
console.log(Object.keys(this.$auth));
19-
},
20-
21-
/**
22-
* Make HTTP request.
23-
*
24-
* @param {Object} $ - Pipedream.
25-
* @param {string} url - API Endpoint URL.
26-
* @param {*} image - Input image.
27-
* Various types are accepted:
28-
* - a path to a file
29-
* - a URL to a file
30-
* - a file's content encoded as a base64 string
31-
* - a file's content as a Buffer encoded in JSON
32-
* - a file's content as an Array of bytes
33-
* @param {Object} params - Query parameters.
34-
* @returns Axios response.
35-
*/
3617
async makeRequest($, url, image, params = {}) {
3718
// Prepare form data.
38-
const base64regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
39-
const urlregex = /^(http|ftp)s?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/;
4019
const form = new FormData();
41-
if (urlregex.test(image)) {
42-
console.log("Input image considered as URL");
43-
form.append("url", image);
44-
}
45-
else {
46-
let buf;
47-
if (image instanceof Buffer) {
48-
console.log("Input image considered as Buffer");
49-
buf = image;
50-
}
51-
else if ((image instanceof Object) && image.type === "Buffer") {
52-
console.log("Input image considered as JSON object with Buffer");
53-
buf = Buffer.from(image);
54-
}
55-
else if (image instanceof Array) {
56-
console.log("Input image considered as Array");
57-
buf = Buffer.from(image);
58-
}
59-
else if (base64regex.test(image)) {
60-
console.log("Input image considered as base64 string");
61-
buf = Buffer.from(image, "base64");
62-
}
63-
else {
64-
console.log("Input image considered as file path");
65-
buf = fs.readFileSync(image);
66-
}
67-
form.append("image", buf);
68-
}
20+
const {
21+
stream, metadata,
22+
} = await getFileStreamAndMetadata(image);
23+
24+
form.append("image", stream, {
25+
contentType: metadata.contentType,
26+
knownLength: metadata.size,
27+
filename: metadata.name,
28+
});
6929

7030
// Prepare headers.
7131
const headers = {

components/api4ai/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/api4ai",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"description": "Pipedream API4AI Components",
55
"main": "api4ai.app.mjs",
66
"keywords": [
@@ -27,7 +27,7 @@
2727
"homepage": "https://pipedream.com/apps/api4ai",
2828
"author": "API4AI Team <[email protected]> (https://api4.ai/)",
2929
"dependencies": {
30-
"@pipedream/platform": "^1.6.2",
30+
"@pipedream/platform": "^3.1.0",
3131
"form-data": "^4.0.0"
3232
},
3333
"publishConfig": {

0 commit comments

Comments
 (0)