cordova-plugin-save-image
Advanced tools
Comparing version 0.1.0 to 0.2.0
{ | ||
"name": "cordova-plugin-save-image", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"cordova": { | ||
@@ -5,0 +5,0 @@ "id": "cordova-plugin-save-image", |
SaveImage | ||
====== | ||
This plugin allows you to save local image files to the iOS Camera Roll/Photo Library or Android Gallery. | ||
This plugin allows you to save local JPEG image files to the iOS Camera Roll/Photo Library or Android Gallery. Other image mime types are currently not supported. | ||
The image file to be saved to the Library/Gallery must be available on the device. | ||
@@ -31,5 +32,5 @@ The plugin is based on code seen in several other existing plugins: | ||
Save an image to the device gallery / camera roll. | ||
Save a local JPEG image to the device gallery / camera roll. | ||
cordova.plugins.imagesaver.saveImageToGallery(nativePathToImage, successCallback, errorCallback); | ||
cordova.plugins.imagesaver.saveImageToGallery(nativePathToJpegImage, successCallback, errorCallback); | ||
@@ -44,7 +45,13 @@ Supported Platforms | ||
Call the `window.cordova.plugins.ImageSaver.saveImageToGallery()` method passing 3 parameters: 1. The native image path for the image to be saved, 2. success callback, 3. error callback: | ||
Call the `window.cordova.plugins.ImageSaver.saveImageToGallery()` method passing 3 parameters: 1. The native image path for the image to be saved, 2. success callback, 3. error callback | ||
### Example | ||
``` | ||
window.cordova.plugins.imagesaver.saveImageToGallery(nativePathToImage, onSaveImageSuccess, onSaveImageError); | ||
// iOS with file prefix: var nativePathToJpegImage = 'file:///var/mobile/Containers/Data/Application/<UUID>/Library/NoCloud/some_dir/some_image.jpg' | ||
// iOS without file prefix: var nativePathToJpegImage = '/var/mobile/Containers/Data/Application/<UUID>/Library/NoCloud/some_dir/some_image.jpg' | ||
// Android with file prefix: var nativePathToJpegImage = 'file:///data/data/<package_name>/files/some_dir/some_image.jpg' | ||
// Android without file prefix: var nativePathToJpegImage = '/data/data/<package_name>/files/some_dir/some_image.jpg' | ||
window.cordova.plugins.imagesaver.saveImageToGallery(nativePathToJpegImage, onSaveImageSuccess, onSaveImageError); | ||
@@ -51,0 +58,0 @@ function onSaveImageSuccess() { |
@@ -13,5 +13,13 @@ var ImageSaver = function () { | ||
return cordova.exec(successCallback, failureCallback, 'SaveImage', 'saveImageToGallery', [localImagePath]); | ||
return cordova.exec( | ||
successCallback, failureCallback, 'SaveImage', 'saveImageToGallery', [_getLocalImagePathWithoutPrefix()]); | ||
function _getLocalImagePathWithoutPrefix() { | ||
if (localImagePath.startsWith('file:///')) { | ||
return localImagePath.substring(7); | ||
} | ||
return localImagePath; | ||
} | ||
}; | ||
module.exports = ImageSaver; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
66871
19
76