Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixing .geojson file not supported with mac os #10082

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export const getFile = (url, fileName = "file") =>
responseType: 'arraybuffer'
}))
.map( res => {
return new File([new Blob([res.data], {type: res.headers['response-type']})], fileName);
const contentType = res.headers['content-type'] === 'null' ? undefined : res.headers['content-type'];
return new File([res.data], fileName, {type: contentType});
});

// PDF_FILE: new File(b64toBlob('UEsDBAoAAAAAACGPaktDvrfoAQAAAAEAAAAKAAAAc2FtcGxlLnR4dGFQSwECPwAKAAAAAAAhj2pLQ7636AEAAAABAAAACgAkAAAAAAAAACAAAAAAAAAAc2FtcGxlLnR4dAoAIAAAAAAAAQAYAGILh+1EWtMBy3f86URa0wHLd/zpRFrTAVBLBQYAAAAAAQABAFwAAAApAAAAAAA=', 'application/pdf'), "file.pdf"),
Expand Down
18 changes: 16 additions & 2 deletions web/client/components/import/dragZone/enhancers/processFiles.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ import {
readWMC,
readZip,
recognizeExt,
shpToGeoJSON
shpToGeoJSON,
readGeoJson
} from '../../../../utils/FileUtils';
import { geoJSONToLayer } from '../../../../utils/LayersUtils';

Expand All @@ -48,7 +49,8 @@ const checkFileType = (file) => {
|| type === 'application/vnd.google-earth.kmz'
|| type === 'application/gpx+xml'
|| type === 'application/json'
|| type === 'application/vnd.wmc') {
|| type === 'application/vnd.wmc'
|| type === 'application/geo+json') {
resolve(file);
} else {
// Drag and drop of compressed folders doesn't correctly send the zip mime type (windows, also conflicts with installations of WinRar)
Expand Down Expand Up @@ -114,6 +116,18 @@ const readFile = (onWarnings) => (file) => {
return [{...f, "fileName": file.name}];
});
}
if (type === 'application/geo+json') {
return readGeoJson(file).then(f => {
const projection = get(f, 'geoJSON.map.projection');
if (projection) {
if (supportedProjections.includes(projection)) {
return [{...f.geoJSON, "fileName": file.name}];
}
throw new Error("PROJECTION_NOT_SUPPORTED");
}
return [{...f.geoJSON, "fileName": file.name}];
});
}
if (type === 'application/vnd.wmc') {
return readWMC(file).then((config) => {
return [{...config, "fileName": file.name}];
Expand Down
Loading