Skip to content

Commit d174051

Browse files
committed
add: askyourpdf
1 parent 49b328f commit d174051

File tree

3 files changed

+12
-16
lines changed

3 files changed

+12
-16
lines changed

components/askyourpdf/actions/add-document-via-file-upload/add-document-via-file-upload.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ export default {
66
name: "Add Document Via File Upload",
77
description: "Add a document via file upload. [See the documentation](https://docs.askyourpdf.com/askyourpdf-docs/#2.-adding-document-via-file-upload)",
88
type: "action",
9-
version: "0.0.2",
9+
version: "0.1.0",
1010
props: {
1111
app,
1212
file: {
1313
type: "string",
14-
label: "File Path",
15-
description: "File path of a file previously downloaded in Pipedream E.g. (`/tmp/my-file.txt`). [Download a file to the `/tmp` directory](https://pipedream.com/docs/code/nodejs/http-requests/#download-a-file-to-the-tmp-directory)",
14+
label: "File Path or URL",
15+
description: "The file to upload. Provide either a path to a file in the `/tmp` directory (e.g. `/tmp/myFile.ext`) or a file URL. [See the documentation on working with files](https://pipedream.com/docs/workflows/building-workflows/code/nodejs/working-with-files/)",
1616
},
1717
},
1818
methods: {

components/askyourpdf/common/utils.mjs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1-
import { createReadStream } from "fs";
1+
import { getFileStream } from "@pipedream/platform";
22
import FormData from "form-data";
33
import constants from "./constants.mjs";
44

5-
function buildFormData(formData, data, parentKey) {
5+
async function buildFormData(formData, data, parentKey) {
66
if (data && typeof(data) === "object") {
7-
Object.keys(data)
8-
.forEach(async (key) => {
9-
buildFormData(formData, data[key], parentKey && `${parentKey}[${key}]` || key);
10-
});
11-
7+
for (const key of Object.keys(data)) {
8+
await buildFormData(formData, data[key], parentKey && `${parentKey}[${key}]` || key);
9+
}
1210
} else if (data && constants.FILE_PROP_NAMES.some((prop) => parentKey.includes(prop))) {
13-
formData.append(parentKey, createReadStream(data));
14-
11+
formData.append(parentKey, await getFileStream(data));
1512
} else if (data) {
1613
formData.append(parentKey, (data).toString());
1714
}

components/askyourpdf/package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/askyourpdf",
3-
"version": "0.1.1",
3+
"version": "0.2.0",
44
"description": "Pipedream AskYourPDF Components",
55
"main": "askyourpdf.app.mjs",
66
"keywords": [
@@ -10,9 +10,8 @@
1010
"homepage": "https://pipedream.com/apps/askyourpdf",
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"dependencies": {
13-
"@pipedream/platform": "^1.6.2",
14-
"form-data": "^4.0.0",
15-
"fs": "^0.0.1-security"
13+
"@pipedream/platform": "^3.1.0",
14+
"form-data": "^4.0.0"
1615
},
1716
"publishConfig": {
1817
"access": "public"

0 commit comments

Comments
 (0)