未验证 提交 f228f559 编写于 作者: O openharmony_ci 提交者: Gitee

!15524 Description modification for Beta5

Merge pull request !15524 from 胡伟奇/cherry-pick-1678093779
...@@ -173,7 +173,7 @@ async function example() { ...@@ -173,7 +173,7 @@ async function example() {
const context = getContext(this); const context = getContext(this);
let media = mediaLibrary.getMediaLibrary(context); let media = mediaLibrary.getMediaLibrary(context);
const path = await media.getPublicDirectory(DIR_DOCUMENTS); const path = await media.getPublicDirectory(DIR_DOCUMENTS);
media.createAsset(mediaType, "testFile.text", path).then((asset) => { media.createAsset(mediaType, "testFile.txt", path).then((asset) => {
console.info("createAsset successfully:" + JSON.stringify(asset)); console.info("createAsset successfully:" + JSON.stringify(asset));
}).catch((err) => { }).catch((err) => {
console.error("createAsset failed with error: " + err); console.error("createAsset failed with error: " + err);
......
...@@ -42,14 +42,11 @@ async function example() { ...@@ -42,14 +42,11 @@ async function example() {
const context = getContext(this); const context = getContext(this);
let media = mediaLibrary.getMediaLibrary(context); let media = mediaLibrary.getMediaLibrary(context);
const fetchFileResult = await media.getFileAssets(option); const fetchFileResult = await media.getFileAssets(option);
fetchFileResult.getFirstObject().then((fileAsset) => { fetchFileResult.getFirstObject().then(async (fileAsset) => {
console.log('getFirstObject.displayName : ' + fileAsset.displayName); console.log('getFirstObject.displayName : ' + fileAsset.displayName);
for (let i = 1; i < fetchFileResult.getCount(); i++) { for (let i = 1; i < fetchFileResult.getCount(); i++) {
fetchFileResult.getNextObject().then((fileAsset) => { let fileAsset = await fetchFileResult.getNextObject();
console.info('fileAsset.displayName ' + i + ': ' + fileAsset.displayName); console.info('fileAsset.displayName ' + i + ': ' + fileAsset.displayName);
}).catch((err) => {
console.error('Failed to get next object: ' + err);
});
} }
}).catch((err) => { }).catch((err) => {
console.error('Failed to get first object: ' + err); console.error('Failed to get first object: ' + err);
...@@ -75,14 +72,11 @@ async function example() { ...@@ -75,14 +72,11 @@ async function example() {
const context = getContext(this); const context = getContext(this);
let media = mediaLibrary.getMediaLibrary(context); let media = mediaLibrary.getMediaLibrary(context);
const fetchFileResult = await media.getFileAssets(option); const fetchFileResult = await media.getFileAssets(option);
fetchFileResult.getFirstObject().then((fileAsset) => { fetchFileResult.getFirstObject().then(async (fileAsset) => {
console.info('getFirstObject.displayName : ' + fileAsset.displayName); console.info('getFirstObject.displayName : ' + fileAsset.displayName);
for (let i = 1; i < fetchFileResult.getCount(); i++) { for (let i = 1; i < fetchFileResult.getCount(); i++) {
fetchFileResult.getNextObject().then((fileAsset) => { let fileAsset = await fetchFileResult.getNextObject();
console.info('fileAsset.displayName ' + i + ': ' + fileAsset.displayName); console.info('fileAsset.displayName ' + i + ': ' + fileAsset.displayName);
}).catch((err) => {
console.error('Failed to get next object: ' + err);
});
} }
}).catch((err) => { }).catch((err) => {
console.error('Failed to get first object: ' + err); console.error('Failed to get first object: ' + err);
...@@ -92,7 +86,7 @@ async function example() { ...@@ -92,7 +86,7 @@ async function example() {
### 按指定顺序排列 ### 按指定顺序排列
下面以查询图片并按文件添加日期降序排列为例。实际开发中可以设置升序(AESC)和降序(DESC)。 下面以查询图片并按文件添加日期降序排列为例。实际开发中可以设置升序(ASC)和降序(DESC)。
order: FileKey.DATE_ADDED,根据文件添加日期排序;并设置排列顺序为DESC降序。 order: FileKey.DATE_ADDED,根据文件添加日期排序;并设置排列顺序为DESC降序。
...@@ -108,14 +102,11 @@ async function example() { ...@@ -108,14 +102,11 @@ async function example() {
const context = getContext(this); const context = getContext(this);
let media = mediaLibrary.getMediaLibrary(context); let media = mediaLibrary.getMediaLibrary(context);
const fetchFileResult = await media.getFileAssets(option); const fetchFileResult = await media.getFileAssets(option);
fetchFileResult.getFirstObject().then((fileAsset) => { fetchFileResult.getFirstObject().then(async (fileAsset) => {
console.info('getFirstObject.displayName : ' + fileAsset.displayName); console.info('getFirstObject.displayName : ' + fileAsset.displayName);
for (let i = 1; i < fetchFileResult.getCount(); i++) { for (let i = 1; i < fetchFileResult.getCount(); i++) {
fetchFileResult.getNextObject().then((fileAsset) => { let fileAsset = await fetchFileResult.getNextObject();
console.info('fileAsset.displayName ' + i + ': ' + fileAsset.displayName); console.info('fileAsset.displayName ' + i + ': ' + fileAsset.displayName);
}).catch((err) => {
console.error('Failed to get next object: ' + err);
});
} }
}).catch((err) => { }).catch((err) => {
console.error('Failed to get first object: ' + err); console.error('Failed to get first object: ' + err);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册