Skip to content

Commit

Permalink
feat(base64-to-gallery): add options interface
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsogl authored Mar 16, 2018
1 parent f11be24 commit 11d516f
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions src/@ionic-native/plugins/base64-to-gallery/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
import { Injectable } from '@angular/core';
import { Cordova, Plugin, IonicNativePlugin } from '@ionic-native/core';
import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';

export interface Base64ToGalleryOptions {
/** Saved file name prefix */
prefix: string;
/**
* 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.
*/
mediaScanner: boolean;
}

/**
* @name Base64 To Gallery
Expand All @@ -19,6 +29,8 @@ import { Cordova, Plugin, IonicNativePlugin } from '@ionic-native/core';
* err => console.log('Error saving image to gallery ', err)
* );
* ```
* @interfaces
* Base64ToGalleryOptions
*/
@Plugin({
pluginName: 'Base64ToGallery',
Expand All @@ -29,19 +41,20 @@ import { Cordova, Plugin, IonicNativePlugin } from '@ionic-native/core';
})
@Injectable()
export class Base64ToGallery extends IonicNativePlugin {

/**
* Converts a base64 string to an image file in the device gallery
* @param {string} data The actual base64 string that you want to save
* @param {any} [options] An object with properties: prefix: string, mediaScanner: boolean. Prefix will be prepended to the filename. If true, mediaScanner runs Media Scanner on Android and saves to Camera Roll on iOS; if false, saves to Library folder on iOS.
* @param {any} [options] An object with properties
* @returns {Promise<any>} returns a promise that resolves when the image is saved.
*/
@Cordova({
successIndex: 2,
errorIndex: 3
})
base64ToGallery(data: string, options?: { prefix?: string; mediaScanner?: boolean }): Promise<any> {
base64ToGallery(
data: string,
options?: Base64ToGalleryOptions
): Promise<any> {
return;
}

}

0 comments on commit 11d516f

Please sign in to comment.