Skip to content

Commit 853f618

Browse files
authored
Part 3 - applying file URL or path improvement (#17149)
* pnpm * Updating _2markdown and mapbox * Akeneo and LLMWhisperer apps * pnpm * add: askyourpdf * add: fileforge * adjusting existing descriptions and platform versions * Description updates * add: microsoft_onedrive, mistral_ai, onlyoffice_docspace * add: slack * add: stannp, zamzar, zoho_desk * add box upload-file * add: monday, nyckel * add: ocrspace * add: onlinecheckwriter, pandadoc, pdf4me * Onedrive adjustment * pnpm * adjusting Slack and Pandadoc * updates to include metadata in all formdatas * pnpm * fix * pnpm * CodeRabbit fixes * Fixing box and nyckel * fix mapbox * pdf4me: readding std filename check to action * initial AI update * add: meistertask, pdffiller, pixelbin * add: platerecognizer, printautopilot, printify * add: printnode,ragie * add: raindrop, ramp, reform * pnpm * AI-generated set * add: roboflow, salesforce_rest_api * add: scrapfly, fix: several * pnpm * add: scoredetect, security_reporter * pnpm * add: sendgrid, sftp * add: signaturit, signerx * add: signnow, smugmug, sonix * add: tinypng, todoist * add: xero_accounting_api, zerobounce, zip_archive_api * add: zoho_bugtracker * add: zoho_catalyst * ESLint and fixes * fix: todoist, xero_accounting_api, zip_archive_api * fix: todoist, zoho_bugtracker * zoho_bugtracker adjustments * pnpm
1 parent 2382aaa commit 853f618

File tree

101 files changed

+631
-822
lines changed

Some content is hidden

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

101 files changed

+631
-822
lines changed

components/avosms/avosms.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};

components/deepsource/deepsource.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};

components/easybroker/easybroker.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};

components/ipstack/ipstack.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};

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

Lines changed: 12 additions & 22 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",
@@ -50,14 +49,6 @@ export default {
5049
optional: true,
5150
},
5251
},
53-
methods: {
54-
checkTmp(filename) {
55-
if (filename.indexOf("/tmp") === -1) {
56-
return `/tmp/${filename}`;
57-
}
58-
return filename;
59-
},
60-
},
6152
async run({ $ }) {
6253
const {
6354
taskId,
@@ -66,16 +57,14 @@ export default {
6657
} = this;
6758

6859
const data = new FormData();
69-
const path = this.checkTmp(filepath);
7060

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,
61+
const {
62+
stream, metadata,
63+
} = await getFileStreamAndMetadata(filepath);
64+
data.append("local", stream, {
65+
contentType: metadata.contentType,
66+
knownLength: metadata.size,
67+
filename: metadata.name,
7968
});
8069
if (name) {
8170
data.append("name", name);
@@ -85,6 +74,7 @@ export default {
8574
};
8675

8776
const response = await this.meistertask.createAttachment({
77+
$,
8878
taskId,
8979
data,
9080
headers,

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 & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import FormData from "form-data";
2-
import fs from "fs";
3-
import { checkTmp } from "../../common/utils.mjs";
2+
import { getFileStreamAndMetadata } from "@pipedream/platform";
43
import pdffiller from "../../pdffiller.app.mjs";
54

65
export default {
76
key: "pdffiller-upload-document",
87
name: "Upload Document",
98
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",
9+
version: "0.1.0",
1110
type: "action",
1211
props: {
1312
pdffiller,
@@ -26,9 +25,15 @@ export default {
2625
},
2726
},
2827
async run({ $ }) {
29-
const fileStream = fs.createReadStream(checkTmp(this.file));
28+
const {
29+
stream, metadata,
30+
} = await getFileStreamAndMetadata(this.file);
3031
const data = new FormData();
31-
data.append("file", fileStream);
32+
data.append("file", stream, {
33+
contentType: metadata.contentType,
34+
knownLength: metadata.size,
35+
filename: metadata.name,
36+
});
3237

3338
if (this.folderId) {
3439
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: 13 additions & 13 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: [
@@ -64,9 +63,6 @@ export default {
6463
uploadFile(args = {}) {
6564
return this.app.post({
6665
path: "/upload/direct",
67-
headers: {
68-
"Content-Type": "multipart/form-data",
69-
},
7066
...args,
7167
});
7268
},
@@ -84,12 +80,15 @@ export default {
8480
filenameOverride,
8581
} = this;
8682

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

9493
utils.appendPropsToFormData(data, {
9594
path,
@@ -104,6 +103,7 @@ export default {
104103
const response = await uploadFile({
105104
$,
106105
data,
106+
headers: data.getHeaders(),
107107
});
108108

109109
$.export("$summary", `Successfully uploaded file with ID \`${response._id}\`.`);

0 commit comments

Comments
 (0)