Get bytes of the file.
Parameters:
Name | Type | Description |
---|---|---|
filePath |
string
|
TypeDefs.FilePath
|
The path of the file to be downloaded. |
Returns:
- Type:
-
Promise.<Uint8Array>
"Promise" returns an array of byte of the file.
Example
// Download file from "/output" path on the browser.
const files = await Gdal.getOutputFiles();
const filePath = files[0].path;
const fileBytes = Gdal.getFileBytes(filePath);
const fileName = filePath.split('/').pop();
saveAs(fileBytes, filename);
function saveAs(fileBytes, fileName) {
const blob = new Blob([fileBytes]);
const link = document.createElement('a');
link.href = URL.createObjectURL(blob);
link.download = fileName;
link.click();
}