Skip to content

Commit 30630a8

Browse files
committed
initial AI update
1 parent d8e872a commit 30630a8

File tree

20 files changed

+138
-94
lines changed

20 files changed

+138
-94
lines changed

components/meistertask/actions/create-attachment/create-attachment.mjs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import meistertask from "../../meistertask.app.mjs";
22
import FormData from "form-data";
3-
import fs from "fs";
4-
import { ConfigurationError } from "@pipedream/platform";
3+
import { getFileStreamAndMetadata } from "@pipedream/platform";
54

65
export default {
76
key: "meistertask-create-attachment",
87
name: "Create Attachment",
98
description: "Create a new attachment. [See the docs](https://developers.meistertask.com/reference/post-attachment)",
10-
version: "0.0.1",
9+
version: "0.1.0",
1110
type: "action",
1211
props: {
1312
meistertask,
@@ -40,8 +39,8 @@ export default {
4039
},
4140
filepath: {
4241
type: "string",
43-
label: "File Path",
44-
description: "Path of the file in /tmp folder to add as an attachment. To upload a file to /tmp folder, please follow the [doc here](https://pipedream.com/docs/code/nodejs/working-with-files/#writing-a-file-to-tmp)",
42+
label: "File Path or URL",
43+
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`)",
4544
},
4645
name: {
4746
type: "string",
@@ -68,14 +67,13 @@ export default {
6867
const data = new FormData();
6968
const path = this.checkTmp(filepath);
7069

71-
if (!fs.existsSync(path)) {
72-
throw new ConfigurationError("File does not exist");
73-
}
74-
75-
const file = fs.createReadStream(path);
76-
const stats = fs.statSync(path);
77-
data.append("local", file, {
78-
knownLength: stats.size,
70+
const {
71+
stream, metadata,
72+
} = getFileStreamAndMetadata(path);
73+
data.append("local", stream, {
74+
contentType: metadata.contentType,
75+
knownLength: metadata.size,
76+
filename: metadata.name,
7977
});
8078
if (name) {
8179
data.append("name", name);

components/meistertask/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/meistertask",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Meistertask Components",
55
"main": "meistertask.app.mjs",
66
"homepage": "https://pipedream.com/apps/meistertask",
@@ -13,6 +13,6 @@
1313
"access": "public"
1414
},
1515
"dependencies": {
16-
"@pipedream/platform": "^1.4.1"
16+
"@pipedream/platform": "^3.1.0"
1717
}
1818
}

components/pdffiller/actions/upload-document/upload-document.mjs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import FormData from "form-data";
2-
import fs from "fs";
2+
import { getFileStreamAndMetadata } from "@pipedream/platform";
33
import { checkTmp } from "../../common/utils.mjs";
44
import pdffiller from "../../pdffiller.app.mjs";
55

66
export default {
77
key: "pdffiller-upload-document",
88
name: "Upload Document",
99
description: "Uploads a chosen file to PDFfiller. [See the documentation](https://docs.pdffiller.com/docs/pdffiller/992d9d79fec32-creates-a-new-document-template-by-uploading-file-from-multipart)",
10-
version: "0.0.2",
10+
version: "0.1.0",
1111
type: "action",
1212
props: {
1313
pdffiller,
@@ -26,9 +26,15 @@ export default {
2626
},
2727
},
2828
async run({ $ }) {
29-
const fileStream = fs.createReadStream(checkTmp(this.file));
29+
const {
30+
stream, metadata,
31+
} = getFileStreamAndMetadata(checkTmp(this.file));
3032
const data = new FormData();
31-
data.append("file", fileStream);
33+
data.append("file", stream, {
34+
contentType: metadata.contentType,
35+
knownLength: metadata.size,
36+
filename: metadata.name,
37+
});
3238

3339
if (this.folderId) {
3440
data.append("folder_id", this.folderId);

components/pdffiller/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/pdffiller",
3-
"version": "0.1.1",
3+
"version": "0.2.0",
44
"description": "Pipedream pdfFiller Components",
55
"main": "pdffiller.app.mjs",
66
"keywords": [
@@ -13,7 +13,7 @@
1313
"access": "public"
1414
},
1515
"dependencies": {
16-
"@pipedream/platform": "^3.0.0",
16+
"@pipedream/platform": "^3.1.0",
1717
"form-data": "^4.0.0",
1818
"fs": "^0.0.1-security"
1919
}

components/pdffiller/pdffiller.app.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ export default {
4444
},
4545
file: {
4646
type: "string",
47-
label: "File",
48-
description: "The path to the file saved to the `/tmp` directory (e.g. `/tmp/example.json`). [See the documentation](https://pipedream.com/docs/workflows/steps/code/nodejs/working-with-files/#the-tmp-directory).",
47+
label: "File Path or URL",
48+
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`)",
4949
},
5050
folderId: {
5151
type: "string",

components/pixelbin/actions/upload-file/upload-file.mjs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1-
import fs from "fs";
21
import FormData from "form-data";
3-
import { ConfigurationError } from "@pipedream/platform";
2+
import { getFileStreamAndMetadata } from "@pipedream/platform";
43
import app from "../../pixelbin.app.mjs";
54
import utils from "../../common/utils.mjs";
65

76
export default {
87
key: "pixelbin-upload-file",
98
name: "Upload File",
109
description: "Upload a file to Pixelbin. [See the documentation](https://www.pixelbin.io/docs/api-docs/)",
11-
version: "0.0.1",
10+
version: "0.1.0",
1211
type: "action",
1312
props: {
1413
app,
1514
filePath: {
1615
type: "string",
17-
label: "File Path",
18-
description: "Assete file path. The path to the file saved to the `/tmp` directory (e.g. `/tmp/example.pdf`). [See the documentation](https://pipedream.com/docs/workflows/steps/code/nodejs/working-with-files/#the-tmp-directory).",
16+
label: "File Path or URL",
17+
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`)",
1918
},
2019
path: {
2120
propDefinition: [
@@ -84,12 +83,15 @@ export default {
8483
filenameOverride,
8584
} = this;
8685

87-
if (!filePath.startsWith("/tmp/")) {
88-
throw new ConfigurationError("File must be located in `/tmp` directory.");
89-
}
90-
86+
const {
87+
stream, metadata: fileMetadata,
88+
} = getFileStreamAndMetadata(filePath);
9189
const data = new FormData();
92-
data.append("file", fs.createReadStream(filePath));
90+
data.append("file", stream, {
91+
contentType: fileMetadata.contentType,
92+
knownLength: fileMetadata.size,
93+
filename: fileMetadata.name,
94+
});
9395

9496
utils.appendPropsToFormData(data, {
9597
path,

components/pixelbin/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/pixelbin",
3-
"version": "0.1.0",
3+
"version": "0.2.0",
44
"description": "Pipedream Pixelbin Components",
55
"main": "pixelbin.app.mjs",
66
"keywords": [
@@ -13,7 +13,7 @@
1313
"access": "public"
1414
},
1515
"dependencies": {
16-
"@pipedream/platform": "3.0.3",
16+
"@pipedream/platform": "^3.1.0",
1717
"form-data": "^4.0.0"
1818
}
1919
}

components/platerecognizer/actions/run-recognition/run-recognition.mjs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
import fs from "fs";
1+
import { getFileStream } from "@pipedream/platform";
22
import { checkTmp } from "../../common/utils.mjs";
33
import platerecognizer from "../../platerecognizer.app.mjs";
44

55
export default {
66
key: "platerecognizer-run-recognition",
77
name: "Run Recognition",
88
description: "Triggers a recognition process using the Plate Recognizer SDK.",
9-
version: "0.0.1",
9+
version: "0.1.0",
1010
type: "action",
1111
props: {
1212
platerecognizer,
1313
imageFileOrUrl: {
1414
type: "string",
1515
label: "Image File or URL",
16-
description: "The image file or URL to be recognized.",
16+
description: "The image file or URL to be recognized. Provide either a file URL or a path to a file in the `/tmp` directory (for example, `/tmp/myImage.jpg`)",
1717
},
1818
regions: {
1919
type: "string[]",
@@ -46,8 +46,13 @@ export default {
4646
if (this.imageFileOrUrl.startsWith("http")) {
4747
fileObj.upload_url = this.imageFileOrUrl;
4848
} else {
49-
const file = fs.readFileSync(checkTmp(this.imageFileOrUrl));
50-
fileObj.upload = Buffer(file).toString("base64");
49+
const { stream } = getFileStream(checkTmp(this.imageFileOrUrl));
50+
const chunks = [];
51+
for await (const chunk of stream) {
52+
chunks.push(chunk);
53+
}
54+
const buffer = Buffer.concat(chunks);
55+
fileObj.upload = buffer.toString("base64");
5156
}
5257

5358
const response = await this.platerecognizer.runRecognition({

components/platerecognizer/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/platerecognizer",
3-
"version": "0.1.0",
3+
"version": "0.2.0",
44
"description": "Pipedream Plate Recognizer Components",
55
"main": "platerecognizer.app.mjs",
66
"keywords": [
@@ -13,7 +13,7 @@
1313
"access": "public"
1414
},
1515
"dependencies": {
16-
"@pipedream/platform": "^1.6.5"
16+
"@pipedream/platform": "^3.1.0"
1717
}
1818
}
1919

components/printautopilot/actions/add-pdf-to-queue/add-pdf-to-queue.mjs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import printAutopilot from "../../printautopilot.app.mjs";
2-
import fs from "fs";
2+
import { getFileStream } from "@pipedream/platform";
33

44
export default {
55
key: "printautopilot-add-pdf-to-queue",
66
name: "Add PDF to Print Autopilot Queue",
77
description: "Uploads a PDF document to the print-autopilot queue. [See the documentation](https://documenter.getpostman.com/view/1334461/TW6wJonb#53f82327-4f23-416d-b2f0-ce17b8037933)",
8-
version: "0.0.1",
8+
version: "0.1.0",
99
type: "action",
1010
props: {
1111
printAutopilot,
1212
filePath: {
1313
type: "string",
14-
label: "File Path",
15-
description: "The path to the file saved to the [`/tmp` directory](https://pipedream.com/docs/workflows/steps/code/nodejs/working-with-files/#the-tmp-directory) (e.g. `/tmp/myFile.pdf`).",
14+
label: "File Path or URL",
15+
description: "The file to upload. Provide either a file URL or a path to a file in the `/tmp` directory (for example, `/tmp/myFile.pdf`)",
1616
},
1717
fileName: {
1818
type: "string",
@@ -30,7 +30,14 @@ export default {
3030
const filePath = this.filePath.includes("/tmp")
3131
? this.filePath
3232
: `/tmp/${this.filePath}`;
33-
const fileContent = Buffer.from(fs.readFileSync(filePath)).toString("base64");
33+
34+
const { stream } = getFileStream(filePath);
35+
const chunks = [];
36+
for await (const chunk of stream) {
37+
chunks.push(chunk);
38+
}
39+
const fileContent = Buffer.concat(chunks).toString("base64");
40+
3441
const response = await this.printAutopilot.addDocumentToQueue({
3542
token: this.token,
3643
data: {

0 commit comments

Comments
 (0)