Base64β
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
- Install the Cordova and Ionic Native plugins:
$ ionic cordova plugin add com-badrit-base64 $ npm install --save @ionic-native/base64@4
- Add this plugin to your app's module
Supported platforms
- Android
- iOS
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