1# File Subsystem Changelog
2
3## cl.file.1 Change of the userFileManager FileAsset Attribute
4
5Changed the [userFileManager.FileAsset](../../../application-dev/reference/apis/js-apis-userFileManager.md#fileasset) attribute.
6
7URI format before the change:
8
9'file://media/\<file_type\>/\<file_id\>/?networkid=xxx'
10
11URI format after the change:
12
13'file://media/Photo/\<id\>/IMG_datetime_0001/displayName.jpg'
14
15**Change Impact**
16
17For applications developed based on earlier versions, check whether the applications depend on or parse the media library URIs. If yes, make adaptation as required. The value of **file_id** is not unique. Do not parse the file ID. Use the URI instead.
18
19**Key API/Component Changes**
20
21| Module                   | Method/Attribute/Enum/Constant                                         | Change Type|
22| ------------------------- | ------------------------------------------------------------ | -------- |
23| userFileManager   |   **interface** FileAsset | Attribute changed    |
24
25**Adaptation Guide**
26
27In API version 10, the URI format of user files is changed so that basic file information (such as the file name) can be obtained based on the URI. If the new format is used, the URI parsing may yield unexpected result. For example, before the change, the ID obtained from the URI **'file://media/image/8'** is 8. If the new URI format is used, the file **displayName** is obtained. You are advised to use the URI to obtain file information.
28
29**Example**:
30
31```js
32import userFileManager from '@ohos.filemanagement.userFileManager';
33import dataSharePredicates from '@ohos.data.dataSharePredicates';
34
35async function example() {
36  let context = getContext(this);
37  let mgr = userFileManager.getUserFileMgr(context);
38  let predicates = new dataSharePredicates.DataSharePredicates();
39  let uri = 'file://media/Photo/1/IMG_datetime_0001/displayName.jpg' // The URI must exist.
40  predicates.equalTo('uri', uri);
41  let fetchOptions = {
42    fetchColumns: ['uri'],
43    predicates: predicates
44  };
45
46  mgr.getPhotoAssets(fetchOptions, async (err, fetchResult) => {
47    if (fetchResult != undefined) {
48      console.info('fetchResult success');
49      let fileAsset = await fetchResult.getFirstObject();
50      if (fileAsset != undefined) {
51        console.info('fileAsset.displayName : ' + fileAsset.displayName);
52      }
53    } else {
54      console.error('fetchResult fail' + err);
55    }
56  });
57}
58```
59
60## cl.file.2 Change of the photoAccessHelper PhotoAsset Attribute
61
62Changed the [photoAccessHelper.PhotoAsset](../../../application-dev/reference/apis/js-apis-photoAccessHelper.md#photoasset) attribute.
63
64URI format before the change:
65
66'file://media/\<file_type\>/\<file_id\>/?networkid=xxx'
67
68URI format after the change:
69
70'file://media/Photo/\<id\>/IMG_datetime_0001/displayName.jpg'
71
72**Change Impact**
73
74For applications developed based on earlier versions, check whether the applications depend on or parse the media library URIs. If yes, make adaptation as required. The value of **file_id** is not unique. Do not parse the file ID. Use the URI instead.
75
76**Key API/Component Changes**
77
78| Module                   | Method/Attribute/Enum/Constant                                         | Change Type|
79| ------------------------- | ------------------------------------------------------------ | -------- |
80| photoAccessHelper   |   **interface** PhotoAsset | Attribute changed    |
81
82**Adaptation Guide**
83
84In API version 10, the URI format of user files is changed so that basic file information (such as the file name) can be obtained based on the URI. If the new format is used, the URI parsing may yield unexpected result. For example, before the change, the ID obtained from the URI **'file://media/image/8'** is 8. If the new URI format is used, the file **displayName** is obtained. You are advised to use the URI to obtain file information.
85
86**Example**:
87
88```js
89import photoAccessHelper from '@ohos.file.photoAccessHelper';
90import dataSharePredicates from '@ohos.data.dataSharePredicates';
91
92async function example() {
93  let context = getContext(this);
94  let phAccessHelper = photoAccessHelper.getPhotoAccessHelper(context);
95  let predicates = new dataSharePredicates.DataSharePredicates();
96  let uri = 'file://media/Photo/1/IMG_datetime_0001/displayName.jpg' // The URI must exist.
97  predicates.equalTo('uri', uri);
98  let fetchOptions = {
99    fetchColumns: ['uri'],
100    predicates: predicates
101  };
102
103  phAccessHelper.getAssets(fetchOptions, async (err, fetchResult) => {
104    if (fetchResult != undefined) {
105      console.info('fetchResult success');
106      let photoAsset = await fetchResult.getFirstObject();
107      if (photoAsset != undefined) {
108        console.info('photoAsset.displayName : ' + photoAsset.displayName);
109      }
110    } else {
111      console.error('fetchResult fail' + err);
112    }
113  });
114}
115```
116