@pipedream/mapbox 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,12 +1,12 @@
1
1
  import mapbox from "../../mapbox.app.mjs";
2
- import fs from "fs";
2
+ import { getFileStreamAndMetadata } from "@pipedream/platform";
3
3
  import FormData from "form-data";
4
4
 
5
5
  export default {
6
6
  key: "mapbox-create-tileset",
7
7
  name: "Create Tileset",
8
8
  description: "Uploads and creates a new tileset from a data source. [See the documentation](https://docs.mapbox.com/api/maps/mapbox-tiling-service/)",
9
- version: "0.0.1",
9
+ version: "0.1.1",
10
10
  type: "action",
11
11
  props: {
12
12
  mapbox,
@@ -22,8 +22,8 @@ export default {
22
22
  },
23
23
  filePath: {
24
24
  type: "string",
25
- label: "File Path",
26
- description: "The path to a tileset source file in the `/tmp` directory. [See the documentation on working with files](https://pipedream.com/docs/code/nodejs/working-with-files/#writing-a-file-to-tmp)",
25
+ label: "File Path or URL",
26
+ description: "A tileset source file. Provide either a file URL or a path to a file in the `/tmp` directory (for example, `/tmp/myFile.txt`)",
27
27
  },
28
28
  recipe: {
29
29
  type: "object",
@@ -42,17 +42,25 @@ export default {
42
42
  description: "Describes whether the tileset must be used with an access token from your Mapbox account. Default is `true`.",
43
43
  optional: true,
44
44
  },
45
+ syncDir: {
46
+ type: "dir",
47
+ accessMode: "read",
48
+ sync: true,
49
+ optional: true,
50
+ },
45
51
  },
46
52
  async run({ $ }) {
47
- const filePath = this.filePath.includes("tmp/")
48
- ? this.filePath
49
- : `/tmp/${this.filePath}`;
50
-
51
53
  // Create Tileset Source
52
54
  try {
53
55
  const fileData = new FormData();
54
- const content = fs.createReadStream(filePath);
55
- fileData.append("file", content);
56
+ const {
57
+ stream, metadata,
58
+ } = await getFileStreamAndMetadata(this.filePath);
59
+ fileData.append("file", stream, {
60
+ contentType: metadata.contentType,
61
+ knownLength: metadata.size,
62
+ filename: metadata.name,
63
+ });
56
64
 
57
65
  await this.mapbox.createTilesetSource({
58
66
  $,
@@ -62,7 +70,7 @@ export default {
62
70
  headers: fileData.getHeaders(),
63
71
  });
64
72
  } catch (e) {
65
- throw new Error(`Error uploading file: \`${filePath}\`. Error: ${e}`);
73
+ throw new Error(`Error uploading file: \`${this.filePath}\`. Error: ${e}`);
66
74
  }
67
75
 
68
76
  const recipe = typeof this.recipe === "string"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/mapbox",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "description": "Pipedream Mapbox Components",
5
5
  "main": "mapbox.app.mjs",
6
6
  "keywords": [
@@ -13,7 +13,7 @@
13
13
  "access": "public"
14
14
  },
15
15
  "dependencies": {
16
- "@pipedream/platform": "^3.0.3",
16
+ "@pipedream/platform": "^3.1.0",
17
17
  "form-data": "^4.0.1"
18
18
  }
19
19
  }