---
name: "saveImageToPhotosAlbum"
mode: "kit"
versionRequirements:
  - { name: "BaseKit", version: "3.11.0" }
  - { name: "@ray-js/ray", version: "1.5.30" }
platform:
  - "iOS"
  - "Android"
async: true
title: "saveImageToPhotosAlbum"
---

## saveImageToPhotosAlbum

> [VERSION] BaseKit >= 3.11.0 | @ray-js/ray >= 1.5.30

> [PLATFORM] iOS, Android

> ⚡ **Supports Promise** — Returns a Promise when success / fail / complete callbacks are omitted.

### Description

Save image to the system album

### Parameters

| Property | Type | Required | Default | Since | Description |
| --- | --- | --- | --- | --- | --- |
| `filePath` | `string` | Yes | - | `3.11.0` | Image file path; can be a temporary or permanent local path |
| `modifyCreationDate` | `boolean` | No | `false` | `3.16.0` | Whether to modify the video's creation date. Default: false (do not modify). true sets the creation date to the current save time. |
| `complete` | `() => void` | No | - | - | Completion callback (executed on both success and failure) |
| `success` | `() => void` | No | - | - | Callback on successful API call |
| `fail` | `(params: Object) => void` ↓see below | No | - | - | Failure callback |

#### fail callback parameters

| Property | Type | Description |
| --- | --- | --- |
| `errorMsg` | `string` | Error message |
| `errorCode` | `string \| number` | Error code |
| `innerError` | `Object` | Error extension |

##### fail(params).innerError properties

| Property | Type | Description |
| --- | --- | --- |
| `errorCode` | `string \| number` | Error extension code |
| `errorMsg` | `string` | Error extension message |


### Examples

#### Demo

```tsx
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),
});
```
