saveImageToPhotosAlbum

Requires:
BaseKit≥3.11.0@ray-js/ray≥1.5.30
Platforms:
iOSAndroid
import { saveImageToPhotosAlbum } from '@ray-js/ray';

// Promise usage
try {
  const res = await saveImageToPhotosAlbum({ ...params });
  console.log(res);
} catch (err) {
  console.log(err.errorMsg);
}

Method signature
saveImageToPhotosAlbum(params: )
Minimum SDK versions
iOSThingSmartBaseKitBizBundle
≥ 5.14.1
Androidcom.thingclips.smart:thingsmart-bizbundle-basekit
≥ 5.14.0

Description

Save image to the system album

Parameters

PropertyTypeRequiredDefaultDescriptionBaseKit SinceMinimum SDK versions
filePathstringYes-Image file path; can be a temporary or permanent local path-—
modifyCreationDatebooleanNofalseWhether to modify the video's creation date. Default: false (do not modify). true sets the creation date to the current save time.v3.16.0
iOSThingSmartBaseKitBizBundle
≥ 6.0.3
Androidcom.thingclips.smart:thingsmart-bizbundle-basekit
≥ 6.0.0
complete() => voidNo-Completion callback (executed on both success and failure)-—
success() => voidNo-Callback on successful API call-—
fail(params: Object) => voidNo-Failure callback-—
fail callback parameters
PropertyTypeDescription
errorMsgstringError message
errorCodestring | numberError code
Error extension

Return Value

None

Examples

import { downloadFile, saveImageToPhotosAlbum } from '@ray-js/ray'

// Save an image to the system album (album permission required): first download the image, then save it using the protocol path
downloadFile({
  url: "https://airtake-public-data-1254153901.cos.ap-shanghai.myqcloud.com/ttttestfile/test_image.jpg",
  success: ({ tempFilePath }) => {
    saveImageToPhotosAlbum({
      filePath: tempFilePath,
      modifyCreationDate: false,
      success: () => console.log("Image saved to album"),
      fail: error => console.error(error),
    });
  },
  fail: error => console.error(error),
});