-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(import-export): EPSG not mandatory and fix encoding issue (#428)
- Loading branch information
Showing
6 changed files
with
70 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* Trigger download of a file | ||
* | ||
* @param content File content | ||
* @param mimeType File mime type | ||
* @param fileName File name | ||
*/ | ||
export function downloadContent(content: string, mimeType: string, fileName: string) { | ||
const uri = `data:${mimeType},${encodeURIComponent(content)}`; | ||
downloadFromUri(uri, fileName); | ||
} | ||
|
||
/** | ||
* Trigger download of a file | ||
* | ||
* @param content File content | ||
* @param mimeType File mime type | ||
* @param fileName File name | ||
*/ | ||
export function downloadFromUri(uri: string, fileName: string) { | ||
const element = document.createElement('a'); | ||
element.setAttribute('href', uri); | ||
element.setAttribute('download', fileName); | ||
element.style.display = 'none'; | ||
document.body.appendChild(element); | ||
|
||
element.click(); | ||
|
||
document.body.removeChild(element); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters