Need help upgrading to Ionic Framework 4.0? Get assistance with our Enterprise Migration Services EXPLORE NOW

Base64β

Improve this doc

This plugin is still in beta stage and may not work as expected. Please submit any issues to the plugin repo.

This Plugin is used to encode base64 of any file, it uses js code for iOS, but in case of android it uses native code to handle android versions lower than v.3

Repo: https://github.com/hazemhagrass/phonegap-base64

Installation

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

Supported platforms

Usage

import { Base64 } from '@ionic-native/base64';

constructor(private base64: Base64) { }

...

let filePath: string = 'file:///...';
this.base64.encodeFile(filePath).then((base64File: string) => {
  console.log(base64File);
}, (err) => {
  console.log(err);
});

Instance Members

encodeFile(filePath)

This function encodes base64 of any file

Param Type Details
filePath string

Absolute file path

Returns: Promise<string> Returns a promise that resolves when the file is successfully encoded

API

Native

General