Got Stuck?
Forum for Lovense Developers
Support
Document Feedback
Save Image
saveImageToPhotosAlbum
Description
Save an image to the system album.
Parameters
Attribute Type Default Required Introduction fileData string Yes Cover the image to base64 string success function No Callback function triggered when the API call successes fail function No Callback function triggered when the API call fails Success callback function will receive an object with the following attributes:
Attribute Type Introduction code string Success code Fail callback function will receive an object with the following attributes:
Attribute Type Introduction code string Error code msg string Error message Example
// Define a saveImageToPhotosAlbum function function saveImageToPhotosAlbum() { // Get file system manager instance const fileSystemManager = appGallery.getFileSystemManager() // Save image file to photo album fileSystemManager.saveImageToPhotosAlbum({ fileData: 'PiIwoN+asbHF55KjSYdIxgKp/gdn19c6teQR2EmVmQJQFQp9FVKnGv6rwU70dzOQSRHh9Q4dNq9eX+DlKkx4JRLH6hhMsRNkn+KIUxuNDR6R+f7//+6dP3pzV+DMnP', success(res) { console.log(res.code) }, fail(err) { console.error(res.code) console.error(res.msg) }, }) }
// Get user manager instance const userManager = appGallery.getUserManager() // Can be passed userManager.getAuthSetting Check to see if the user is authorized "scope.writePhotosAlbum" this scope userManager.getAuthSetting({ success(res) { if (!res.authSetting['scope.writePhotosAlbum']) { userManager.authorize({ scope: 'scope.writePhotosAlbum', success(res) { // The user has agreed that the mini-app will use the save image to photo album function, and then calls saveImageToPhotosAlbum Interface does not pop up to ask saveImageToPhotosAlbum() }, fail(err) { console.error(err) } }) } else { saveImageToPhotosAlbum() } }, fail(err) { console.error(err) } })