@pipedream/mapbox 0.1.0 → 0.2.0
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
|
|
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
|
|
9
|
+
version: "0.1.0",
|
|
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: "
|
|
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",
|
|
@@ -44,15 +44,17 @@ export default {
|
|
|
44
44
|
},
|
|
45
45
|
},
|
|
46
46
|
async run({ $ }) {
|
|
47
|
-
const filePath = this.filePath.includes("tmp/")
|
|
48
|
-
? this.filePath
|
|
49
|
-
: `/tmp/${this.filePath}`;
|
|
50
|
-
|
|
51
47
|
// Create Tileset Source
|
|
52
48
|
try {
|
|
53
49
|
const fileData = new FormData();
|
|
54
|
-
const
|
|
55
|
-
|
|
50
|
+
const {
|
|
51
|
+
stream, metadata,
|
|
52
|
+
} = await getFileStreamAndMetadata(this.filePath);
|
|
53
|
+
fileData.append("file", stream, {
|
|
54
|
+
contentType: metadata.contentType,
|
|
55
|
+
knownLength: metadata.size,
|
|
56
|
+
filename: metadata.name,
|
|
57
|
+
});
|
|
56
58
|
|
|
57
59
|
await this.mapbox.createTilesetSource({
|
|
58
60
|
$,
|
|
@@ -62,7 +64,7 @@ export default {
|
|
|
62
64
|
headers: fileData.getHeaders(),
|
|
63
65
|
});
|
|
64
66
|
} catch (e) {
|
|
65
|
-
throw new Error(`Error uploading file: \`${filePath}\`. Error: ${e}`);
|
|
67
|
+
throw new Error(`Error uploading file: \`${this.filePath}\`. Error: ${e}`);
|
|
66
68
|
}
|
|
67
69
|
|
|
68
70
|
const recipe = typeof this.recipe === "string"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pipedream/mapbox",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
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
|
|
16
|
+
"@pipedream/platform": "^3.1.0",
|
|
17
17
|
"form-data": "^4.0.1"
|
|
18
18
|
}
|
|
19
19
|
}
|