Fix file downloads from notebooks container (#196)

* Fix file downloads from notebooks container

* Add downloading message
This commit is contained in:
Tanuj Mittal
2020-09-11 19:37:00 -07:00
committed by GitHub
parent 83b13de685
commit 728eeefa17
3 changed files with 42 additions and 12 deletions

17
src/Utils/BlobUtils.ts Normal file
View File

@@ -0,0 +1,17 @@
export const stringToBlob = (data: string, contentType: string, sliceSize = 512): Blob => {
const byteArrays = [];
for (let offset = 0; offset < data.length; offset += sliceSize) {
const slice = data.slice(offset, offset + sliceSize);
const byteNumbers = new Array(slice.length);
for (let i = 0; i < slice.length; i++) {
byteNumbers[i] = slice.charCodeAt(i);
}
const byteArray = new Uint8Array(byteNumbers);
byteArrays.push(byteArray);
}
return new Blob(byteArrays, { type: contentType });
};