Sahil
Sahil

Reputation: 553

base64 data URL to blob and then write file ionic

i have converted canvas to data url.

 var dataUrl = this._CANVAS.toDataURL('image/jpeg', 0.7);

how to convert dataURL to blob and then save it as a image file in app folder ionic.?

Upvotes: 0

Views: 2874

Answers (1)

Mahesh Jadhav
Mahesh Jadhav

Reputation: 1089

You can directly save your dataUrl(base64 image) to your gallery no need to convert it to blog with this ionic native base64 to gallery plugin, it saves your base64 encoded image to gallery

Get your DataUrl without passing type to it just use

var dataUrl = this._CANVAS.toDataURL() 

after you get your dataURL :

this.base64ToGallery.base64ToGallery(dataUrl, { prefix: '_img' }) // pass your variable dataUrl and it will save it to your storage.

one more important thing after installing the plugin check if it saves the image to your gallery because most of the times it won't(on android device as i used android can't say the same about ios devices) because you may not have your WRITE_EXTERNAL_STORAGE permissions set, so for that i had to use one more plugin android permissions which checked the required permissions and then i was able to save the image to gallery

Upvotes: 1

Related Questions