2016-07-08 06:37:05 +08:00
|
|
|
import { Cordova, Plugin } from './plugin';
|
2016-12-06 21:02:00 +08:00
|
|
|
|
2016-03-14 01:39:29 +08:00
|
|
|
/**
|
|
|
|
* @name Base64 To Gallery
|
|
|
|
* @description This plugin allows you to save base64 data as a png image into the device
|
|
|
|
* @usage
|
2016-07-20 23:17:09 +08:00
|
|
|
* ```typescript
|
|
|
|
* import { Base64ToGallery } from 'ionic-native';
|
2016-03-25 01:00:18 +08:00
|
|
|
*
|
|
|
|
*
|
2016-03-14 01:39:29 +08:00
|
|
|
* Base64ToGallery.base64ToGallery(base64Data, 'img_').then(
|
2016-07-20 23:17:09 +08:00
|
|
|
* res => console.log('Saved image to gallery ', res),
|
|
|
|
* err => console.log('Error saving image to gallery ', err)
|
2016-03-14 01:39:29 +08:00
|
|
|
* );
|
|
|
|
* ```
|
|
|
|
*/
|
|
|
|
@Plugin({
|
2016-10-28 01:48:50 +08:00
|
|
|
pluginName: 'Base64ToGallery',
|
2016-03-14 01:39:29 +08:00
|
|
|
plugin: 'cordova-base64-to-gallery',
|
|
|
|
pluginRef: 'cordova',
|
2016-03-15 01:38:35 +08:00
|
|
|
repo: 'https://github.com/Nexxa/cordova-base64-to-gallery',
|
2016-04-30 11:56:49 +08:00
|
|
|
platforms: ['Android', 'iOS', 'Windows Phone 8']
|
2016-03-14 01:39:29 +08:00
|
|
|
})
|
|
|
|
export class Base64ToGallery {
|
|
|
|
|
|
|
|
/**
|
2016-03-26 06:05:13 +08:00
|
|
|
* Converts a base64 string to an image file in the device gallery
|
2016-07-06 04:11:27 +08:00
|
|
|
* @param {string} data The actual base64 string that you want to save
|
2016-10-18 09:33:17 +08:00
|
|
|
* @param {any} options (optional) 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.
|
2016-11-30 06:40:50 +08:00
|
|
|
* @returns {Promise<any>} returns a promise that resolves when the image is saved.
|
2016-03-14 01:39:29 +08:00
|
|
|
*/
|
2016-09-01 05:01:50 +08:00
|
|
|
@Cordova({
|
|
|
|
successIndex: 2,
|
|
|
|
errorIndex: 3
|
|
|
|
})
|
2016-07-20 19:12:44 +08:00
|
|
|
static base64ToGallery(data: string, options?: {prefix?: string; mediaScanner?: boolean}): Promise<any> {
|
2016-04-30 11:56:49 +08:00
|
|
|
return;
|
2016-03-14 01:39:29 +08:00
|
|
|
}
|
|
|
|
|
2016-07-06 04:11:27 +08:00
|
|
|
}
|