1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 | import { CreatePublicGeoJSONMapDataRequest } from "./gen/model/createPublicGeoJSONMapDataRequest";
import { ReadStream } from "fs";
import FormData from "form-data";
import axios from "axios";
import { BackgroundLayersAndAreasOfInterestMapdataApi } from "./gen/api/backgroundLayersAndAreasOfInterestMapdataApi";
import { Readable } from "stream";
import { PublicMapDataDTO } from "./gen/model/publicMapDataDTO";
export async function createGeoJSONMapData(
request: CreatePublicGeoJSONMapDataRequest,
contentsStream: ReadStream | Readable,
jwtToken: string
): Promise<PublicMapDataDTO> {
const form = new FormData();
form.append("json", JSON.stringify(request), { contentType: "application/json" });
form.append("file", contentsStream, { filename: "data.geojson" });
const headers = form.getHeaders();
headers["Content-Type"] = "multipart/form-data";
headers["Authorization"] = `Bearer ${jwtToken}`;
const basePath = new BackgroundLayersAndAreasOfInterestMapdataApi().basePath;
return (await axios.post(`${basePath}/public/api/mapdata/geojson`, form, { headers: headers }))
.data;
}
|