Skip to content

Commit 5f17db7

Browse files
committed
some adjusts
1 parent ceb186a commit 5f17db7

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

components/ocrspace/actions/process-pdf/process-pdf.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default {
1515
"file",
1616
],
1717
label: "PDF File",
18-
description: "The URL of the PDF file or the path to the file saved to the `/tmp` directory (e.g. `/tmp/example.jpg`) to process. [See the documentation](https://pipedream.com/docs/workflows/steps/code/nodejs/working-with-files/#the-tmp-directory).",
18+
description: "The URL of the PDF file or the path to the file saved to the `/tmp` directory (e.g. `/tmp/example.pdf`) to process. [See the documentation](https://pipedream.com/docs/workflows/steps/code/nodejs/working-with-files/#the-tmp-directory).",
1919
},
2020
},
2121
methods: {

components/ocrspace/common/utils.mjs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import fs from "fs";
2+
import mime from "mime";
23

34
export const isValidUrl = (urlString) => {
45
var urlPattern = new RegExp("^(https?:\\/\\/)?" + // validate protocol
@@ -19,10 +20,12 @@ export const checkTmp = (filename) => {
1920

2021
export const getUrlOrFile = (url) => {
2122
if (!isValidUrl(url)) {
22-
const data = fs.readFileSync(checkTmp(url));
23+
const filePath = checkTmp(url);
24+
const data = fs.readFileSync(filePath);
25+
const mimeType = mime.getType(filePath);
2326
const base64Image = Buffer.from(data, "binary").toString("base64");
2427
return {
25-
file: `data:image/jpeg;base64,${base64Image}`,
28+
file: `data:${mimeType};base64,${base64Image}`,
2629
};
2730
}
2831
return {

components/ocrspace/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"access": "public"
1414
},
1515
"dependencies": {
16-
"@pipedream/platform": "^3.0.3"
16+
"@pipedream/platform": "^3.0.3",
17+
"mime": "^4.0.6"
1718
}
1819
}

0 commit comments

Comments
 (0)