Skip to content
Advertisement

Converting base64 to blob in javascript

I tried to convert a JPEG’s base64 string to a blob on a Cordova/hybrid app running on iOS 8 using the following function b64toBlob.

JavaScript

However it’s giving an error

JavaScript

when we do

JavaScript

How can be work around this error?

Advertisement

Answer

Try this out. Please note that dataURI is assumed to include base64 prefix. (e.g. "data:image/jpeg;base64,")

JavaScript

Usage:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement