The **MediaLibrary** class of the multimedia component is replaced by the **FilePicker** class.
All APIs provided by the mediaLibrary module of the multimedia subsystem are deprecated.
**Change Impact**
**Change Impact**
For applications developed based on earlier versions, pay attention to the changes of APIs. **FilePicker** is a system application preset in OpenHarmony. You can use it to select and save files.
All APIs described in [mediaLibrary](../../../application-dev/reference/apis/js-apis-medialibrary.md) are deprecated. Third-party applications can only select and save files in the public directory by calling the APIs of [FilePicker](../../../application-dev/reference/apis/js-apis-file-picker.md).
For applications developed based on earlier versions, pay attention to the changes of APIs.
**Key API/Component Changes**
**Key API/Component Changes**
The APIs of **MediaLibrary**, located in **@ohos.multimedia.medialibrary**, are deprecated. The **FilePicker** class, located in [@ohos.file.picker](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.file.picker.d.ts) is used.
The table below lists the **mediaLibrary** APIs that can be substituted by the **FilePicker** APIs.
console.info('mediaLibrary fileAsset open fd: '+fd);
letwriteLen=fs.writeSync(fd,'hello, world');
console.info('write data to file succeed and size is: '+writeLen);
fileAsset.close(fd);
fetchFileResult.close();
media.release();
}catch(err){
console.error('mediaLibrary fail, err: '+err);
}
}
```
**The following example shows how to use the FilePicker APIs to edit a file in the public directory:**
1. Obtain a **DocumentViewPicker** object.
2. Call **DocumentViewPicker.select** to select a file.
3. After a file is selected, a file URI is returned.
4. After the UI is returned from DocumentViewPicker, call [fs.openSync](../../../application-dev/reference/apis/js-apis-file-fs.md#fsopensync) to open the file based on the URI and obtain the FD.
5. Call [fs.writeSync](../../../application-dev/reference/apis/js-apis-file-fs.md#writesync) to edit the file through the FD.
6. After the edit, call [fs.closeSync](../../../application-dev/reference/apis/js-apis-file-fs.md#closesync) to close the FD.
console.error("PhotoViewPicker.select PhotoSelectResult is undefined");
console.info('mediaLibrary fileAsset open fd: '+fd);
letwriteLen=fs.writeSync(fd,'hello, world');
console.info('write data to file succeed and size is: '+writeLen);
fileAsset.close(fd);
media.release();
}catch(err){
console.error('mediaLibrary fail, err: '+err);
}
}
}
```
**The following example shows how to use the FilePicker APIs to create a file in the public directory:**
1. Obtain a **DocumentViewPicker** object.
2. Call **DocumentViewPicker.save** to create and save an empty file.
3. After the file is saved, a file URI is returned.
4. After the UI is returned from DocumentViewPicker, call [fs.openSync](../../../application-dev/reference/apis/js-apis-file-fs.md#fsopensync) to open the file based on the URI and obtain the FD.
5. Call [fs.writeSync](../../../application-dev/reference/apis/js-apis-file-fs.md#writesync) to edit the file through the FD.
6. After the edit, call [fs.closeSync](../../../application-dev/reference/apis/js-apis-file-fs.md#closesync) to close the FD.
The table below lists the mediaLibrary APIs that are not open to third-party applications due to function control. There are no substitute APIs for them.