Ionic Framework 4 is almost here. Preview the beta docs and try it out now! Try Ionic 4 Beta

Base64 To Gallery

Improve this doc

This plugin allows you to save base64 data as a png image into the device

Repo: https://github.com/Nexxa/cordova-base64-to-gallery

Installation

  1. Install the Cordova and Ionic Native plugins:
    $ ionic cordova plugin add cordova-base64-to-gallery
    $ npm install --save @ionic-native/base64-to-gallery
    
  2. Add this plugin to your app's module

Supported platforms

Usage

import { Base64ToGallery } from '@ionic-native/base64-to-gallery';

constructor(private base64ToGallery: Base64ToGallery) { }


...


this.base64ToGallery.base64ToGallery(base64Data, { prefix: '_img' }).then(
  res => console.log('Saved image to gallery ', res),
  err => console.log('Error saving image to gallery ', err)
);

Instance Members

base64ToGallery(data, options)

Converts a base64 string to an image file in the device gallery

Param Type Details
data string

The actual base64 string that you want to save

options any

An object with propertiesOptional

Returns: Promise<any> returns a promise that resolves when the image is saved.

Base64ToGalleryOptions

Param Type Details
prefix string

Saved file name prefix

mediaScanner boolean

On Android runs Media Scanner after file creation. On iOS if true the file will be added to camera roll, otherwise will be saved to a library folder.

API

Native

General