1e41f4b71Sopenharmony_ci# File Management Subsystem Changelog 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci## cl.file.1 mediaLibrary APIs Changed 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ciThe **MediaLibrary** class of the multimedia component is replaced by the **FilePicker** class. 6e41f4b71Sopenharmony_ci 7e41f4b71Sopenharmony_ci**Change Impact** 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ciFor 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. 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ci**Key API/Component Changes** 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ciThe 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. 14e41f4b71Sopenharmony_ci 15e41f4b71Sopenharmony_ci| Module | Method/Attribute/Enum/Constant | Change Type| 16e41f4b71Sopenharmony_ci| ------------------------- | ------------------------------------------------------------ | -------- | 17e41f4b71Sopenharmony_ci| medialibrary | **function** getMediaLibrary(): MediaLibrary; | Deprecated | 18e41f4b71Sopenharmony_ci| medialibrary | **function** getMediaLibrary(context: Context): MediaLibrary; | Deprecated | 19e41f4b71Sopenharmony_ci| medialibrary | **function** getFileAssets(options: MediaFetchOptions, callback: AsyncCallback\<FetchFileResult\>): void | Deprecated | 20e41f4b71Sopenharmony_ci| medialibrary | **function** getFileAssets(options: MediaFetchOptions): Promise\<FetchFileResult\> | Deprecated | 21e41f4b71Sopenharmony_ci| medialibrary | **function** on(type: 'deviceChange'\|'albumChange'\|'imageChange'\|'audioChange'\|'videoChange'\|'fileChange'\|'remoteFileChange', callback: Callback\<void\>): void | Deprecated | 22e41f4b71Sopenharmony_ci| medialibrary | **function** off(type: 'deviceChange'\|'albumChange'\|'imageChange'\|'audioChange'\|'videoChange'\|'fileChange'\|'remoteFileChange', callback?: Callback\<void\>): void | Deprecated | 23e41f4b71Sopenharmony_ci| medialibrary | **function** createAsset(mediaType: MediaType, displayName: string, relativePath: string, callback: AsyncCallback\<FileAsset\>): void | Deprecated | 24e41f4b71Sopenharmony_ci| medialibrary | **function** createAsset(mediaType: MediaType, displayName: string, relativePath: string): Promise\<FileAsset\> | Deprecated | 25e41f4b71Sopenharmony_ci| medialibrary | **function** deleteAsset(uri: string): Promise\<void\> | Deprecated | 26e41f4b71Sopenharmony_ci| medialibrary | **function** deleteAsset(uri: string, callback: AsyncCallback\<void\>): void | Deprecated | 27e41f4b71Sopenharmony_ci| medialibrary | **function** getPublicDirectory(type: DirectoryType, callback: AsyncCallback\<string\>): void | Deprecated | 28e41f4b71Sopenharmony_ci| medialibrary | **function** getPublicDirectory(type: DirectoryType): Promise\<string\> | Deprecated | 29e41f4b71Sopenharmony_ci| medialibrary | **function** getAlbums(options: MediaFetchOptions, callback: AsyncCallback\<Array\<Album\>\>): void | Deprecated | 30e41f4b71Sopenharmony_ci| medialibrary | **function** getAlbums(options: MediaFetchOptions): Promise\<Array\<Album\>\> | Deprecated | 31e41f4b71Sopenharmony_ci| medialibrary | **function** release(callback: AsyncCallback\<void\>): void | Deprecated | 32e41f4b71Sopenharmony_ci| medialibrary | **function** release(): Promise\<void\> | Deprecated | 33e41f4b71Sopenharmony_ci| medialibrary | **function** storeMediaAsset(option: MediaAssetOption, callback: AsyncCallback\<string\>): void | Deprecated | 34e41f4b71Sopenharmony_ci| medialibrary | **function** storeMediaAsset(option: MediaAssetOption): Promise\<string\> | Deprecated | 35e41f4b71Sopenharmony_ci| medialibrary | **function** startImagePreview(images: Array\<string\>, index: number, callback: AsyncCallback\<void\>): void | Deprecated | 36e41f4b71Sopenharmony_ci| medialibrary | **function** startImagePreview(images: Array\<string\>, callback: AsyncCallback\<void\>): void | Deprecated | 37e41f4b71Sopenharmony_ci| medialibrary | **function** startImagePreview(images: Array\<string\>, index?: number): Promise\<void\> | Deprecated | 38e41f4b71Sopenharmony_ci| medialibrary | **function** startMediaSelect(option: MediaSelectOption, callback: AsyncCallback\<Array\<string\>\>): void | Deprecated | 39e41f4b71Sopenharmony_ci| medialibrary | **function** startMediaSelect(option: MediaSelectOption): Promise\<Array\<string\>\> | Deprecated | 40e41f4b71Sopenharmony_ci| medialibrary | **function** getActivePeers(): Promise\<Array\<PeerInfo\>\>; | Deprecated | 41e41f4b71Sopenharmony_ci| medialibrary | **function** getActivePeers(callback: AsyncCallback\<Array\<PeerInfo\>\>): void; | Deprecated | 42e41f4b71Sopenharmony_ci| medialibrary | **function** getAllPeers(): Promise\<Array\<PeerInfo\>\>; | Deprecated | 43e41f4b71Sopenharmony_ci| medialibrary | **function** FileAsset.isDirectory(callback: AsyncCallback\<boolean\>): void | Deprecated | 44e41f4b71Sopenharmony_ci| medialibrary | **function** FileAsset.isDirectory():Promise\<boolean\> | Deprecated | 45e41f4b71Sopenharmony_ci| medialibrary | **function** FileAsset.commitModify(callback: AsyncCallback\<void\>): void | Deprecated | 46e41f4b71Sopenharmony_ci| medialibrary | **function** FileAsset.commitModify(): Promise\<void\> | Deprecated | 47e41f4b71Sopenharmony_ci| medialibrary | **function** FileAsset.open(mode: string, callback: AsyncCallback\<number\>): void | Deprecated | 48e41f4b71Sopenharmony_ci| medialibrary | **function** FileAsset.open(mode: string): Promise\<number\> | Deprecated | 49e41f4b71Sopenharmony_ci| medialibrary | **function** FileAsset.close(fd: number, callback: AsyncCallback\<void\>): void | Deprecated | 50e41f4b71Sopenharmony_ci| medialibrary | **function** FileAsset.close(fd: number): Promise\<void\> | Deprecated | 51e41f4b71Sopenharmony_ci| medialibrary | **function** FileAsset.getThumbnail(callback: AsyncCallback\<image.PixelMap\>): void | Deprecated | 52e41f4b71Sopenharmony_ci| medialibrary | **function** FileAsset.getThumbnail(size: Size, callback: AsyncCallback\<image.PixelMap\>): void | Deprecated | 53e41f4b71Sopenharmony_ci| medialibrary | **function** FileAsset.getThumbnail(size?: Size): Promise\<image.PixelMap\> | Deprecated | 54e41f4b71Sopenharmony_ci| medialibrary | **function** FileAsset.favorite(isFavorite: boolean, callback: AsyncCallback\<void\>): void | Deprecated | 55e41f4b71Sopenharmony_ci| medialibrary | **function** FileAsset.favorite(isFavorite: boolean): Promise\<void\> | Deprecated | 56e41f4b71Sopenharmony_ci| medialibrary | **function** FileAsset.isFavorite(callback: AsyncCallback\<boolean\>): void | Deprecated | 57e41f4b71Sopenharmony_ci| medialibrary | **function** FileAsset.isFavorite():Promise\<boolean\> | Deprecated | 58e41f4b71Sopenharmony_ci| medialibrary | **function** FileAsset.trash(isTrash: boolean, callback: AsyncCallback\<void\>): void | Deprecated | 59e41f4b71Sopenharmony_ci| medialibrary | **function** FileAsset.trash(isTrash: boolean): Promise\<void\> | Deprecated | 60e41f4b71Sopenharmony_ci| medialibrary | **function** FileAsset.isTrash(callback: AsyncCallback\<boolean\>): void | Deprecated | 61e41f4b71Sopenharmony_ci| medialibrary | **function** FileAsset.isTrash():Promise\<boolean\> | Deprecated | 62e41f4b71Sopenharmony_ci| medialibrary | **function** FetchFileResult.getCount(): number | Deprecated | 63e41f4b71Sopenharmony_ci| medialibrary | **function** FetchFileResult.isAfterLast(): boolean | Deprecated | 64e41f4b71Sopenharmony_ci| medialibrary | **function** FetchFileResult.close(): void | Deprecated | 65e41f4b71Sopenharmony_ci| medialibrary | **function** FetchFileResult.getFirstObject(callback: AsyncCallback\<FileAsset\>): void | Deprecated | 66e41f4b71Sopenharmony_ci| medialibrary | **function** FetchFileResult.getFirstObject(): Promise\<FileAsset\> | Deprecated | 67e41f4b71Sopenharmony_ci| medialibrary | **function** FetchFileResult.getNextObject(callback: AsyncCallback\<FileAsset\>): void | Deprecated | 68e41f4b71Sopenharmony_ci| medialibrary | **function** FetchFileResult.getNextObject(): Promise\<FileAsset\> | Deprecated | 69e41f4b71Sopenharmony_ci| medialibrary | **function** FetchFileResult.getLastObject(callback: AsyncCallback\<FileAsset\>): void | Deprecated | 70e41f4b71Sopenharmony_ci| medialibrary | **function** FetchFileResult.getLastObject(): Promise\<FileAsset\> | Deprecated | 71e41f4b71Sopenharmony_ci| medialibrary | **function** FetchFileResult.getPositionObject(index: number, callback: AsyncCallback\<FileAsset\>): void | Deprecated | 72e41f4b71Sopenharmony_ci| medialibrary | **function** FetchFileResult.getPositionObject(index: number): Promise\<FileAsset\> | Deprecated | 73e41f4b71Sopenharmony_ci| medialibrary | **function** FetchFileResult.getAllObject(callback: AsyncCallback\<Array\<FileAsset\>\>): void | Deprecated | 74e41f4b71Sopenharmony_ci| medialibrary | **function** FetchFileResult.getAllObject(): Promise\<Array\<FileAsset\>\> | Deprecated | 75e41f4b71Sopenharmony_ci| medialibrary | **function** Album.commitModify(callback: AsyncCallback\<void\>): void | Deprecated | 76e41f4b71Sopenharmony_ci| medialibrary | **function** Album.commitModify(): Promise\<void\> | Deprecated | 77e41f4b71Sopenharmony_ci| medialibrary | **function** Album.getFileAssets(options: MediaFetchOptions, callback: AsyncCallback\<FetchFileResult\>): void | Deprecated | 78e41f4b71Sopenharmony_ci| medialibrary | **function** Album.getFileAssets(options?: MediaFetchOptions): Promise\<FetchFileResult\> | Deprecated | 79e41f4b71Sopenharmony_ci| medialibrary | **enum** DeviceType | Deprecated | 80e41f4b71Sopenharmony_ci| medialibrary | **enum** FileKey | Deprecated | 81e41f4b71Sopenharmony_ci| medialibrary | **enum** DirectoryType | Deprecated | 82e41f4b71Sopenharmony_ci| medialibrary | **enum** MediaType | Deprecated | 83e41f4b71Sopenharmony_ci| medialibrary | **interface** PeerInfo | Deprecated | 84e41f4b71Sopenharmony_ci| medialibrary | **interface** Size | Deprecated | 85e41f4b71Sopenharmony_ci| medialibrary | **interface** MediaFetchOptions | Deprecated | 86e41f4b71Sopenharmony_ci| medialibrary | **interface** MediaAssetOption | Deprecated | 87e41f4b71Sopenharmony_ci| medialibrary | **interface** MediaSelectOption | Deprecated | 88e41f4b71Sopenharmony_ci| medialibrary | **interface** FileAsset | Deprecated | 89e41f4b71Sopenharmony_ci 90e41f4b71Sopenharmony_ci**Adaptation Guide** 91e41f4b71Sopenharmony_ci 92e41f4b71Sopenharmony_ciFor example, refer to the code snippet below to call an API to select an image: 93e41f4b71Sopenharmony_ci 94e41f4b71Sopenharmony_ci```js 95e41f4b71Sopenharmony_ciimport picker from '@ohos.file.picker'; 96e41f4b71Sopenharmony_ci 97e41f4b71Sopenharmony_ciasync function example() { 98e41f4b71Sopenharmony_ci try { 99e41f4b71Sopenharmony_ci let PhotoSelectOptions = new picker.PhotoSelectOptions(); 100e41f4b71Sopenharmony_ci PhotoSelectOptions.MIMEType = picker.PhotoViewMIMETypes.IMAGE_TYPE; 101e41f4b71Sopenharmony_ci PhotoSelectOptions.maxSelectNumber = 1; 102e41f4b71Sopenharmony_ci let photoPicker = new picker.PhotoViewPicker(); 103e41f4b71Sopenharmony_ci photoPicker.select(PhotoSelectOptions).then((PhotoSelectResult) => { 104e41f4b71Sopenharmony_ci if (PhotoSelectResult !== undefined) { 105e41f4b71Sopenharmony_ci console.info("PhotoViewPicker.select pass, PhotoSelectResult uri: " + JSON.stringify(PhotoSelectResult)); 106e41f4b71Sopenharmony_ci } else { 107e41f4b71Sopenharmony_ci console.error("PhotoViewPicker.select PhotoSelectResult is undefined"); 108e41f4b71Sopenharmony_ci } 109e41f4b71Sopenharmony_ci }).catch((err) => { 110e41f4b71Sopenharmony_ci console.error("PhotoViewPicker.select fail, err: " + err); 111e41f4b71Sopenharmony_ci }); 112e41f4b71Sopenharmony_ci } catch (err) { 113e41f4b71Sopenharmony_ci console.error("PhotoViewPicker fail, err: " + err); 114e41f4b71Sopenharmony_ci } 115e41f4b71Sopenharmony_ci} 116e41f4b71Sopenharmony_ci``` 117