Skip to content

Commit afafc5c

Browse files
authored
fixing .geojson file not supported with mac os (#10082)
* #10081 FixBug .geojson file not supported in macos. - In macOS .geojson file will be identified as type of "application/geo+json". So in checkFileType and readFile functions, they will not go into MIME_LOOKUPS list to find the corresponding type. - Check first in MIME_LOOKUPS list and then the file.type will solve this problem. On behalf of DB Systel GmbH * #10082 FixBug .geojson file not supported in macos. - added codes to support geojson in processFiles.jsx - fixed bug in testData.js in order to give a type by initialing a new File instance On behalf of DB Systel GmbH
1 parent f90b853 commit afafc5c

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

web/client/components/import/dragZone/enhancers/__tests__/testData.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ export const getFile = (url, fileName = "file") =>
1616
responseType: 'arraybuffer'
1717
}))
1818
.map( res => {
19-
return new File([new Blob([res.data], {type: res.headers['response-type']})], fileName);
19+
const contentType = res.headers['content-type'] === 'null' ? undefined : res.headers['content-type'];
20+
return new File([res.data], fileName, {type: contentType});
2021
});
2122

2223
// PDF_FILE: new File(b64toBlob('UEsDBAoAAAAAACGPaktDvrfoAQAAAAEAAAAKAAAAc2FtcGxlLnR4dGFQSwECPwAKAAAAAAAhj2pLQ7636AEAAAABAAAACgAkAAAAAAAAACAAAAAAAAAAc2FtcGxlLnR4dAoAIAAAAAAAAQAYAGILh+1EWtMBy3f86URa0wHLd/zpRFrTAVBLBQYAAAAAAQABAFwAAAApAAAAAAA=', 'application/pdf'), "file.pdf"),

web/client/components/import/dragZone/enhancers/processFiles.jsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ import {
2424
readWMC,
2525
readZip,
2626
recognizeExt,
27-
shpToGeoJSON
27+
shpToGeoJSON,
28+
readGeoJson
2829
} from '../../../../utils/FileUtils';
2930
import { geoJSONToLayer } from '../../../../utils/LayersUtils';
3031

@@ -48,7 +49,8 @@ const checkFileType = (file) => {
4849
|| type === 'application/vnd.google-earth.kmz'
4950
|| type === 'application/gpx+xml'
5051
|| type === 'application/json'
51-
|| type === 'application/vnd.wmc') {
52+
|| type === 'application/vnd.wmc'
53+
|| type === 'application/geo+json') {
5254
resolve(file);
5355
} else {
5456
// Drag and drop of compressed folders doesn't correctly send the zip mime type (windows, also conflicts with installations of WinRar)
@@ -114,6 +116,18 @@ const readFile = (onWarnings) => (file) => {
114116
return [{...f, "fileName": file.name}];
115117
});
116118
}
119+
if (type === 'application/geo+json') {
120+
return readGeoJson(file).then(f => {
121+
const projection = get(f, 'geoJSON.map.projection');
122+
if (projection) {
123+
if (supportedProjections.includes(projection)) {
124+
return [{...f.geoJSON, "fileName": file.name}];
125+
}
126+
throw new Error("PROJECTION_NOT_SUPPORTED");
127+
}
128+
return [{...f.geoJSON, "fileName": file.name}];
129+
});
130+
}
117131
if (type === 'application/vnd.wmc') {
118132
return readWMC(file).then((config) => {
119133
return [{...config, "fileName": file.name}];

0 commit comments

Comments
 (0)