@pipedream/platerecognizer 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,19 +1,18 @@
1
- import fs from "fs";
2
- import { checkTmp } from "../../common/utils.mjs";
1
+ import { getFileStream } from "@pipedream/platform";
3
2
  import platerecognizer from "../../platerecognizer.app.mjs";
4
3
 
5
4
  export default {
6
5
  key: "platerecognizer-run-recognition",
7
6
  name: "Run Recognition",
8
7
  description: "Triggers a recognition process using the Plate Recognizer SDK.",
9
- version: "0.0.1",
8
+ version: "0.1.1",
10
9
  type: "action",
11
10
  props: {
12
11
  platerecognizer,
13
12
  imageFileOrUrl: {
14
13
  type: "string",
15
- label: "Image File or URL",
16
- description: "The image file or URL to be recognized.",
14
+ label: "Image Path or URL",
15
+ description: "The image to be recognized. Provide either a file URL or a path to a file in the `/tmp` directory (for example, `/tmp/myImage.jpg`)",
17
16
  },
18
17
  regions: {
19
18
  type: "string[]",
@@ -39,21 +38,26 @@ export default {
39
38
  description: "Additional configuration. [See further details here](https://guides.platerecognizer.com/docs/snapshot/api-reference/#engine-configuration)",
40
39
  optional: true,
41
40
  },
41
+ syncDir: {
42
+ type: "dir",
43
+ accessMode: "read",
44
+ sync: true,
45
+ optional: true,
46
+ },
42
47
  },
43
48
  async run({ $ }) {
44
- const fileObj = {};
45
49
 
46
- if (this.imageFileOrUrl.startsWith("http")) {
47
- fileObj.upload_url = this.imageFileOrUrl;
48
- } else {
49
- const file = fs.readFileSync(checkTmp(this.imageFileOrUrl));
50
- fileObj.upload = Buffer(file).toString("base64");
50
+ const stream = await getFileStream(this.imageFileOrUrl);
51
+ const chunks = [];
52
+ for await (const chunk of stream) {
53
+ chunks.push(chunk);
51
54
  }
55
+ const buffer = Buffer.concat(chunks);
52
56
 
53
57
  const response = await this.platerecognizer.runRecognition({
54
58
  $,
55
59
  data: {
56
- ...fileObj,
60
+ upload: buffer.toString("base64"),
57
61
  regions: this.regions,
58
62
  camera_id: this.cameraId,
59
63
  mmc: this.mmc,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/platerecognizer",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "description": "Pipedream Plate Recognizer Components",
5
5
  "main": "platerecognizer.app.mjs",
6
6
  "keywords": [
@@ -13,6 +13,6 @@
13
13
  "access": "public"
14
14
  },
15
15
  "dependencies": {
16
- "@pipedream/platform": "^1.6.5"
16
+ "@pipedream/platform": "^3.1.0"
17
17
  }
18
18
  }