cordova plugin for saving base64 image
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Base64ImageSaverPlugin.js 1.1KB

123456789101112131415161718192021222324252627282930
  1. //
  2. // Base64ImageSaverPlugin.js
  3. // Base64ImageSaverPlugin PhoneGap/Cordova plugin
  4. //
  5. // Created by Tommy-Carlos Williams on 29/03/12.
  6. // Modified by Simba Zhang on 09/10/2015
  7. // Copyright (c) 2012 Tommy-Carlos Williams. All rights reserved.
  8. // MIT Licensed
  9. //
  10. module.exports = {
  11. saveImageDataToLibrary:function(successCallback, failureCallback, base64Data) {
  12. // successCallback required
  13. if (typeof successCallback != "function") {
  14. console.log("Base64ImageSaverPlugin Error: successCallback is not a function");
  15. }
  16. else if (typeof failureCallback != "function") {
  17. console.log("Base64ImageSaverPlugin Error: failureCallback is not a function");
  18. }
  19. else if (typeof base64Data != "string") {
  20. console.log("Base64ImageSaverPlugin Error: base64Data is not a string");
  21. }
  22. else {
  23. var imageData = base64Data.replace(/data:image\/png;base64,/,'');
  24. return cordova.exec(successCallback, failureCallback, "Base64ImageSaverPlugin","saveImageDataToLibrary",[imageData]);
  25. }
  26. }
  27. };