b64-to-blob
b64-to-blob copied to clipboard
Import with Typescript
Hi,
thanks for the library :)
I'm trying to use it within an Angular app (and Typescript).
If I import it like that:
import b64toBlob from 'b64-to-blob';
and then use it like that:
const contentType = 'image/png';
const blob = b64toBlob(base64Img, contentType);
const blobUrl = URL.createObjectURL(blob);
I get an error because b64toBlob
is undefined.
So I had to do the following instead:
import * as b64toBlob from 'b64-to-blob';
const contentType = 'image/png';
const blob = (b64toBlob as any)(base64Img, contentType);
const blobUrl = URL.createObjectURL(blob);
And the typing is not good anymore with that kind of import so I had to type the b64toBlob
function as any. Not sure how to deal with that but maybe you'll have an idea :smile: