> ## Documentation Index
> Fetch the complete documentation index at: https://docs.phones.farm/llms.txt
> Use this file to discover all available pages before exploring further.

# Media Management

> Managing device media libraries, programmatic photo/video transfer, and album import/export endpoints.

## 1.Album Management

Provides background management functionality for iOS device albums. After screen mirroring starts, you can perform CRUD operations on device albums.

💡 Prerequisites

Album management features can only be used after device screen mirroring starts. The system maintains album state and interfaces in the background.

### Feature Overview

#### 📱 iOS Album Management

When device screen mirroring starts, iClick maintains iOS device album management interfaces in the background, supporting the following operations:

| Operation | Description | Interface Name |
| - | - | - |
| 📋 **Query** | Get list of photos and videos in album | `queryMediaFile` |
| ➕ **Add** | Add photos or videos to album | `addMediaFile` |
| 🗑️ **Delete** | Delete photos or videos from album | `delMediaFile` |

## 2.Get File List

Get list of photos and videos in device album.

### Endpoint Description

#### Endpoint Type

```
queryMediaFile
```

#### Parameters

| Parameter | Type | Required | Description |
| - | - | - | - |
| `deviceId` | string | ✅ | Device ID |

#### Response Payload

Returns array of media files:

```
[
    {
        name: "IMG_0001.JPG",
        ext: 'mp4', 
        mtime: "2024-01-01 10:00:00",
    },
    // More files...
]
```

### Basic Usage

```
// Get device album file list
const mediaFiles = await apiInvoke('queryMediaFile', {
    deviceId: 'P72578581E07'
});

console.log(`Total ${mediaFiles.length} files in album`);
```

## 3.Get Media File

Get specified file from device album and automatically save to local, return saved file path.

Endpoint Description

#### Endpoint Type

```
getMediaFile
```

#### Parameters

| Parameter | Type | Required | Description |
| - | - | - | - |
| `deviceId` | string | ✅ | Device ID |
| `fileName` | string | ✅ | File name |

#### Response Payload

Returns local path of saved file (string):

```
"C:/AppData/Temp/IMG_0001.JPG"  // Full path of local file
```

💡 Note

iClick will automatically download file from device and save to local temp directory. The returned path is the saved file path, which you can use directly to access the file.

### Basic Usage

```
// Get specified file
const localPath = await apiInvoke('getMediaFile', {
    deviceId: 'P72578581E07',
    fileName: 'IMG_0001.JPG'
});

console.log('File saved to:', localPath);
// Output: D:/AppData/Temp/IMG_0001.JPG
```

## 4.Delete Media File

Delete specified photo or video file in device album.

### Endpoint Description

#### Endpoint Type

```
delMediaFile
```

#### Parameters

| Parameter | Type | Required | Description |
| - | - | - | - |
| `deviceId` | string | ✅ | Device ID |
| `fileName` | string | ✅ | File name to delete |

#### Response Payload

```
true  // Returns true on successful deletion
```

🤖 Auto Operation

iClick will automatically handle deletion confirmation prompt on device, no need to manually click confirmation button. System will automatically recognize and click delete confirmation dialog, the entire process is fully automated.

### Basic Usage

```
// Delete specified file
await apiInvoke('delMediaFile', {
    deviceId: 'P72578581E07',
    fileName: 'IMG_0001.JPG'
});

console.log('File deleted');
```

## 5.Save to Album

Upload local file (photo or video) and save to device album.

### Endpoint Description

#### Endpoint Type

```
saveMediaFile
```

#### Parameters

| Parameter | Type | Required | Description |
| - | - | - | - |
| `deviceId` | string | ✅ | Device ID |
| `file` | string | ✅ | Full path of local file |

#### Response Payload

```
true  // Returns true on successful save
```

### Basic Usage

```
// Save local photo to device album
await apiInvoke('saveMediaFile', {
    deviceId: 'P72578581E07',
    file: 'D:/Photos/test.jpg'
});

console.log('File saved to album');
```

## 6.Clean Album

One-click clean all photos and videos in device album.

### Endpoint Description

#### Endpoint Type

```
clearMediaFile
```

#### Parameters

| Parameter | Type | Required | Description |
| - | - | - | - |
| `deviceId` | string | ✅ | Device ID |

#### Response Payload

```
true  // Returns true on successful cleaning
```

🤖 Auto Operation

iClick will automatically handle deletion confirmation prompt on device, no need to manually click confirmation button. System will automatically recognize and click delete confirmation dialog, the entire cleaning process is fully automated, you just need to wait for completion.

### Basic Usage

```
// Clean device album
await apiInvoke('clearMediaFile', {
    deviceId: 'P72578581E07'
});

console.log('Album cleaned');
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.