From 793e2e34d34ddc8d5bfe8abb10eac50cb500a34d Mon Sep 17 00:00:00 2001 From: "Lucas A. Moulin" Date: Sat, 3 Jun 2017 17:04:32 -0300 Subject: [PATCH] feat(base64): add Base64 plugin (#1645) * Add base64 plugin * Add base64 plugin * Apply requested changes --- src/@ionic-native/plugins/base64/index.ts | 45 +++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/@ionic-native/plugins/base64/index.ts diff --git a/src/@ionic-native/plugins/base64/index.ts b/src/@ionic-native/plugins/base64/index.ts new file mode 100644 index 000000000..c43fda67d --- /dev/null +++ b/src/@ionic-native/plugins/base64/index.ts @@ -0,0 +1,45 @@ +import { Injectable } from '@angular/core'; +import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core'; + +/** + * @beta + * @name Base64 + * @description + * 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 + * + * @usage + * ```typescript + * 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); + * }); + * + * ``` + */ +@Plugin({ + pluginName: 'Base64', + plugin: 'com-badrit-base64', + pluginRef: 'plugins.Base64', + repo: 'https://github.com/hazemhagrass/phonegap-base64', + platforms: ['Android', 'iOS'] +}) +@Injectable() +export class Base64 extends IonicNativePlugin { + + /** + * This function encodes base64 of any file + * @param {string} filePath Absolute file path + * @return {Promise} Returns a promise that resolves when the file is successfully encoded + */ + @Cordova() + encodeFile(filePath: string): Promise { return; } + +}