Skip to content

Commit c104045

Browse files
committed
add: microsoft_onedrive, mistral_ai, onlyoffice_docspace
1 parent 9bf8aad commit c104045

File tree

8 files changed

+34
-45
lines changed

8 files changed

+34
-45
lines changed

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import onedrive from "../../microsoft_onedrive.app.mjs";
2-
import { ConfigurationError } from "@pipedream/platform";
3-
import fs from "fs";
2+
import {
3+
ConfigurationError, getFileStream,
4+
} from "@pipedream/platform";
45
import { fileTypeFromStream } from "file-type";
56

67
export default {
78
name: "Upload File",
89
description: "Upload a file to OneDrive. [See the documentation](https://learn.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_put_content?view=odsp-graph-online)",
910
key: "microsoft_onedrive-upload-file",
10-
version: "0.1.2",
11+
version: "0.2.0",
1112
type: "action",
1213
props: {
1314
onedrive,
@@ -21,8 +22,8 @@ export default {
2122
},
2223
filePath: {
2324
type: "string",
24-
label: "File Path",
25-
description: "The path to the file saved to the `/tmp` directory (e.g. `/tmp/image.png`). [See the documentation](https://pipedream.com/docs/workflows/steps/code/nodejs/working-with-files/#the-tmp-directory).",
25+
label: "File Path or URL",
26+
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`)",
2627
},
2728
filename: {
2829
type: "string",
@@ -39,7 +40,7 @@ export default {
3940
throw new ConfigurationError("You must specify the **Upload Folder ID**.");
4041
}
4142

42-
let stream = fs.createReadStream(filePath);
43+
let stream = await getFileStream(filePath);
4344
let name = filename;
4445

4546
if (!filename.includes(".")) {
@@ -48,7 +49,7 @@ export default {
4849
name = `${filename}.${extension}`;
4950

5051
stream.destroy();
51-
stream = fs.createReadStream(filePath);
52+
stream = await getFileStream(filePath);
5253
}
5354

5455
const response = await this.onedrive.uploadFile({

components/microsoft_onedrive/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/microsoft_onedrive",
3-
"version": "1.6.2",
3+
"version": "1.7.0",
44
"description": "Pipedream Microsoft OneDrive components",
55
"main": "microsoft_onedrive.app.mjs",
66
"homepage": "https://pipedream.com/apps/microsoft-onedrive",
@@ -10,7 +10,7 @@
1010
},
1111
"dependencies": {
1212
"@microsoft/microsoft-graph-client": "^3.0.1",
13-
"@pipedream/platform": "^3.0.3",
13+
"@pipedream/platform": "^3.1.0",
1414
"bottleneck": "^2.19.5",
1515
"file-type": "^18.7.0",
1616
"isomorphic-fetch": "^3.0.0",

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

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
import mistralAI from "../../mistral_ai.app.mjs";
2-
import { ConfigurationError } from "@pipedream/platform";
3-
import fs from "fs";
2+
import { getFileStream } from "@pipedream/platform";
43
import FormData from "form-data";
54

65
export default {
76
key: "mistral_ai-upload-file",
87
name: "Upload File",
98
description: "Upload a file that can be used across various endpoints. [See the Documentation](https://docs.mistral.ai/api/#tag/files/operation/files_api_routes_upload_file)",
10-
version: "0.0.1",
9+
version: "0.1.0",
1110
type: "action",
1211
props: {
1312
mistralAI,
1413
filePath: {
1514
type: "string",
16-
label: "File Path",
17-
description: "The path to a file in the `/tmp` directory. The size of individual files can be a maximum of 512 MB. The Fine-tuning API only supports .jsonl files. [See the Pipedream documentation on working with files](https://pipedream.com/docs/code/nodejs/working-with-files/#writing-a-file-to-tmp)",
15+
label: "File Path or URL",
16+
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`)",
1817
},
1918
purpose: {
2019
type: "string",
@@ -29,15 +28,7 @@ export default {
2928
},
3029
},
3130
async run({ $ }) {
32-
const filePath = this.filePath.startsWith("/tmp/")
33-
? this.filePath
34-
: `/tmp/${this.filePath}`;
35-
36-
if (!fs.existsSync(filePath)) {
37-
throw new ConfigurationError(`File \`${filePath}\` not found`);
38-
}
39-
40-
const fileContent = fs.createReadStream(filePath);
31+
const fileContent = await getFileStream(this.filePath);
4132
const form = new FormData();
4233
form.append("file", fileContent);
4334
if (this.purpose) {

components/mistral_ai/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/mistral_ai",
3-
"version": "0.1.0",
3+
"version": "0.2.0",
44
"description": "Pipedream Mistral AI Components",
55
"main": "mistral_ai.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.2"
1818
}
1919
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "onlyoffice_docspace-upload-file",
66
name: "Upload File",
77
description: "Uploads a file to the specified room. [See the documentation](https://api.onlyoffice.com/docspace/method/files/post/api/2.0/files/%7bfolderid%7d/upload)",
8-
version: "0.0.1",
8+
version: "0.1.0",
99
type: "action",
1010
props: {
1111
app,
@@ -19,8 +19,8 @@ export default {
1919
},
2020
file: {
2121
type: "string",
22-
label: "File",
23-
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)",
22+
label: "File Path or URL",
23+
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`)",
2424
},
2525
},
2626
methods: {

components/onlyoffice_docspace/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((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/onlyoffice_docspace/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/onlyoffice_docspace",
3-
"version": "0.1.0",
3+
"version": "0.2.0",
44
"description": "Pipedream ONLYOFFICE DocSpace Components",
55
"main": "onlyoffice_docspace.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
}
1919
}

pnpm-lock.yaml

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

0 commit comments

Comments
 (0)