Skip to content

Commit 11d516f

Browse files
authored
feat(base64-to-gallery): add options interface
1 parent f11be24 commit 11d516f

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

src/@ionic-native/plugins/base64-to-gallery/index.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
import { Injectable } from '@angular/core';
2-
import { Cordova, Plugin, IonicNativePlugin } from '@ionic-native/core';
2+
import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
3+
4+
export interface Base64ToGalleryOptions {
5+
/** Saved file name prefix */
6+
prefix: string;
7+
/**
8+
* On Android runs Media Scanner after file creation.
9+
* On iOS if true the file will be added to camera roll, otherwise will be saved to a library folder.
10+
*/
11+
mediaScanner: boolean;
12+
}
313

414
/**
515
* @name Base64 To Gallery
@@ -19,6 +29,8 @@ import { Cordova, Plugin, IonicNativePlugin } from '@ionic-native/core';
1929
* err => console.log('Error saving image to gallery ', err)
2030
* );
2131
* ```
32+
* @interfaces
33+
* Base64ToGalleryOptions
2234
*/
2335
@Plugin({
2436
pluginName: 'Base64ToGallery',
@@ -29,19 +41,20 @@ import { Cordova, Plugin, IonicNativePlugin } from '@ionic-native/core';
2941
})
3042
@Injectable()
3143
export class Base64ToGallery extends IonicNativePlugin {
32-
3344
/**
3445
* Converts a base64 string to an image file in the device gallery
3546
* @param {string} data The actual base64 string that you want to save
36-
* @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.
47+
* @param {any} [options] An object with properties
3748
* @returns {Promise<any>} returns a promise that resolves when the image is saved.
3849
*/
3950
@Cordova({
4051
successIndex: 2,
4152
errorIndex: 3
4253
})
43-
base64ToGallery(data: string, options?: { prefix?: string; mediaScanner?: boolean }): Promise<any> {
54+
base64ToGallery(
55+
data: string,
56+
options?: Base64ToGalleryOptions
57+
): Promise<any> {
4458
return;
4559
}
46-
4760
}

0 commit comments

Comments
 (0)