Base64

Contents

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

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

Ionic 文件转换成Base64插件的安装(Installation)

ionic cordova plugin add com-badrit-base64 npm install @ionic-native/base64

Ionic 文件转换成Base64插件支持的平台(Supported Platforms)

  • Android
  • iOS

Ionic 文件转换成Base64插件的用法(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);
});