Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
237303b7
D
Docs
项目概览
OpenHarmony
/
Docs
1 年多 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
237303b7
编写于
8月 29, 2023
作者:
O
openharmony_ci
提交者:
Gitee
8月 29, 2023
浏览文件
操作
浏览文件
下载
差异文件
!23366 修复示例代码编译告警
Merge pull request !23366 from 胡伟奇/demo_update
上级
a98c6006
513ffd03
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
120 addition
and
109 deletion
+120
-109
zh-cn/application-dev/reference/apis/js-apis-photoAccessHelper.md
...plication-dev/reference/apis/js-apis-photoAccessHelper.md
+61
-55
zh-cn/application-dev/reference/apis/js-apis-userFileManager.md
...application-dev/reference/apis/js-apis-userFileManager.md
+59
-54
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-photoAccessHelper.md
浏览文件 @
237303b7
...
...
@@ -1315,37 +1315,36 @@ getPhotoIndex(photoUri: string, albumUri: string, options: FetchOptions, callbac
import
dataSharePredicates
from
'
@ohos.data.dataSharePredicates
'
;
async
function
example
()
{
console
.
info
(
'
getPhotoIndexDemo
'
);
let
predicatesForGetAsset
=
new
dataSharePredicates
.
DataSharePredicates
(
);
let
fetchOp
=
{
fetchColumns
:
[],
predicates
:
predicatesForGetAsset
};
//Obtain the uri of the album
let
albumFetchResult
=
await
helper
.
getAlbums
(
photoAccessHelper
.
AlbumType
.
SYSTEM
,
photoAccessHelper
.
AlbumSubtype
.
FAVORITE
,
fetchOp
);
let
album
=
await
albumFetchResult
.
getFirstObject
(
);
let
predicates
=
new
dataSharePredicates
.
DataSharePredicates
();
predicates
.
orderByAsc
(
"
add_modified
"
);
let
fetchOptions
=
{
fetchColumns
:
[
],
predicates
:
predicates
};
let
photoFetchResult
=
await
album
.
getAssets
(
fetchOptions
);
let
expectIndex
=
1
;
//
Obtain the uri of the second file
let
photoAsset
=
await
photoFetchResult
.
getObjectByPosition
(
expectIndex
);
try
{
console
.
info
(
'
getPhotoIndexDemo
'
);
let
predicatesForGetAsset
=
new
dataSharePredicates
.
DataSharePredicates
();
let
fetchOp
=
{
fetchColumns
:
[],
predicates
:
predicatesForGetAsset
};
// Obtain the uri of the album
let
albumFetchResult
=
await
phAccessHelper
.
getAlbums
(
photoAccessHelper
.
AlbumType
.
SYSTEM
,
photoAccessHelper
.
AlbumSubtype
.
FAVORITE
,
fetchOp
);
let
album
=
await
albumFetchResult
.
getFirstObject
();
let
predicates
=
new
dataSharePredicates
.
DataSharePredicates
();
predicates
.
orderByAsc
(
photoAccessHelper
.
PhotoKeys
.
DATE_MODIFIED
);
let
fetchOptions
=
{
fetchColumns
:
[
photoAccessHelper
.
PhotoKeys
.
DATE_MODIFIED
],
predicates
:
predicates
};
let
photoFetchResult
=
await
album
.
getAssets
(
fetchOptions
);
let
expectIndex
=
1
;
//
Obtain the uri of the second file
let
photoAsset
=
await
photoFetchResult
.
getObjectByPosition
(
expectIndex
);
photoAccessHelper
.
getPhotoIndex
(
photoAsset
.
uri
,
album
.
albumUri
,
fetchOptions
,
(
err
,
index
)
=>
{
try
{
phAccessHelper
.
getPhotoIndex
(
photoAsset
.
uri
,
album
.
albumUri
,
fetchOptions
,
(
err
,
index
)
=>
{
if
(
err
==
undefined
)
{
console
.
info
(
`getPhotoIndex successfully and index is :
${
index
}
`
);
}
else
{
console
.
info
(
`getPhotoIndex failed;`
);
}
}
catch
(
error
)
{
console
.
info
(
`getPhotoIndex failed; error:
${
error
}
`
);
}
}
);
}
catch
(
error
)
{
console
.
info
(
`getPhotoIndex failed; error:
${
error
}
`
);
}
}
```
...
...
@@ -1390,33 +1389,34 @@ getPhotoIndex(photoUri: string, albumUri: string, options: FetchOptions): Promis
import
dataSharePredicates
from
'
@ohos.data.dataSharePredicates
'
;
async
function
example
()
{
console
.
info
(
'
getPhotoIndexDemo
'
);
let
predicatesForGetAsset
=
new
dataSharePredicates
.
DataSharePredicates
();
let
fetchOp
=
{
fetchColumns
:
[],
predicates
:
predicatesForGetAsset
};
//Obtain the uri of the album
let
albumFetchResult
=
await
helper
.
getAlbums
(
photoAccessHelper
.
AlbumType
.
SYSTEM
,
photoAccessHelper
.
AlbumSubtype
.
FAVORITE
,
fetchOp
);
let
album
=
await
albumFetchResult
.
getFirstObject
();
let
predicates
=
new
dataSharePredicates
.
DataSharePredicates
();
predicates
.
orderByAsc
(
"
add_modified
"
);
let
fetchOptions
=
{
fetchColumns
:
[],
predicates
:
predicates
};
let
photoFetchResult
=
await
album
.
getAssets
(
fetchOptions
);
let
expectIndex
=
1
;
//Obtain the uri of the second file
let
photoAsset
=
await
photoFetchResult
.
getObjectByPosition
(
expectIndex
);
photoAccessHelper
.
getPhotoIndex
(
photoAsset
.
uri
,
album
.
albumUri
,
fetchOptions
)
.
then
((
index
)
=>
{
console
.
info
(
`getPhotoIndex successfully and index is :
${
index
}
`
);
}).
catch
((
err
)
=>
{
try
{
console
.
info
(
'
getPhotoIndexDemo
'
);
let
predicatesForGetAsset
=
new
dataSharePredicates
.
DataSharePredicates
();
let
fetchOp
=
{
fetchColumns
:
[],
predicates
:
predicatesForGetAsset
};
// Obtain the uri of the album
let
albumFetchResult
=
await
phAccessHelper
.
getAlbums
(
photoAccessHelper
.
AlbumType
.
SYSTEM
,
photoAccessHelper
.
AlbumSubtype
.
FAVORITE
,
fetchOp
);
let
album
=
await
albumFetchResult
.
getFirstObject
();
let
predicates
=
new
dataSharePredicates
.
DataSharePredicates
();
predicates
.
orderByAsc
(
photoAccessHelper
.
PhotoKeys
.
DATE_MODIFIED
);
let
fetchOptions
=
{
fetchColumns
:
[
photoAccessHelper
.
PhotoKeys
.
DATE_MODIFIED
],
predicates
:
predicates
};
let
photoFetchResult
=
await
album
.
getAssets
(
fetchOptions
);
let
expectIndex
=
1
;
// Obtain the uri of the second file
let
photoAsset
=
await
photoFetchResult
.
getObjectByPosition
(
expectIndex
);
phAccessHelper
.
getPhotoIndex
(
photoAsset
.
uri
,
album
.
albumUri
,
fetchOptions
).
then
((
index
)
=>
{
console
.
info
(
`getPhotoIndex successfully and index is :
${
index
}
`
);
}).
catch
((
err
)
=>
{
console
.
info
(
`getPhotoIndex failed; error:
${
err
}
`
);
})
});
}
catch
(
error
)
{
console
.
info
(
`getPhotoIndex failed; error:
${
error
}
`
);
}
}
```
...
...
@@ -2394,7 +2394,7 @@ getExif(): Promise<string>
返回jpg格式图片Exif标签组成的json格式的字符串,该方法使用Promise方式返回结果。
**注意**
:此接口返回的是exif标签组成的json格式的字符串,完整exif信息由all_exif与
p
hotoKeys.USER_COMMENT组成,fetchColumns需要传入这两个字段。
**注意**
:此接口返回的是exif标签组成的json格式的字符串,完整exif信息由all_exif与
P
hotoKeys.USER_COMMENT组成,fetchColumns需要传入这两个字段。
**系统接口**
:此接口为系统接口。
...
...
@@ -2459,15 +2459,18 @@ async function example() {
try
{
console
.
info
(
'
getExifDemo
'
);
let
predicates
=
new
dataSharePredicates
.
DataSharePredicates
();
predicates
.
isNotNull
(
'
all_exif
'
)
let
fetchOptions
=
{
fetchColumns
:
[
'
all_exif
'
,
p
hotoKeys
.
USER_COMMENT
],
fetchColumns
:
[
'
all_exif
'
,
photoAccessHelper
.
P
hotoKeys
.
USER_COMMENT
],
predicates
:
predicates
};
let
fetchResult
=
await
phAccessHelper
.
getAssets
(
fetchOptions
);
let
fileAsset
=
await
fetchResult
.
getFirstObject
();
console
.
info
(
'
getExifDemo fileAsset displayName:
'
+
JSON
.
stringify
(
fileAsset
.
displayName
));
let
exifMessage
=
await
fileAsset
.
getExif
();
let
userCommentKey
=
'
UserComment
'
;
let
userComment
=
JSON
.
stringify
(
JSON
.
parse
(
exifMessage
),
[
userCommentKey
]);
console
.
info
(
'
getExifDemo userComment:
'
+
JSON
.
stringify
(
userComment
));
fetchResult
.
close
();
}
catch
(
err
)
{
console
.
error
(
'
getExifDemoCallback failed with error:
'
+
err
);
...
...
@@ -2481,7 +2484,7 @@ getExif(callback: AsyncCallback<string>): void
返回jpg格式图片Exif标签组成的json格式的字符串,该方法使用Promise方式返回结果。
**注意**
:此接口返回的是exif标签组成的json格式的字符串,完整exif信息由all_exif与
p
hotoKeys.USER_COMMENT组成,fetchColumns需要传入这两个字段。
**注意**
:此接口返回的是exif标签组成的json格式的字符串,完整exif信息由all_exif与
P
hotoKeys.USER_COMMENT组成,fetchColumns需要传入这两个字段。
**系统接口**
:此接口为系统接口。
...
...
@@ -2546,16 +2549,19 @@ async function example() {
try
{
console
.
info
(
'
getExifDemo
'
);
let
predicates
=
new
dataSharePredicates
.
DataSharePredicates
();
predicates
.
isNotNull
(
'
all_exif
'
)
let
fetchOptions
=
{
fetchColumns
:
[
'
all_exif
'
,
p
hotoKeys
.
USER_COMMENT
],
fetchColumns
:
[
'
all_exif
'
,
photoAccessHelper
.
P
hotoKeys
.
USER_COMMENT
],
predicates
:
predicates
};
let
fetchResult
=
await
phAccessHelper
.
getAssets
(
fetchOptions
);
let
fileAsset
=
await
fetchResult
.
getFirstObject
();
console
.
info
(
'
getExifDemo fileAsset displayName:
'
+
JSON
.
stringify
(
fileAsset
.
displayName
));
let
userCommentKey
=
'
UserComment
'
;
fileAsset
.
getExif
((
err
,
exifMessage
)
=>
{
if
(
exifMessage
!=
undefined
)
{
let
userComment
=
JSON
.
stringify
(
JSON
.
parse
(
exifMessage
),
[
userCommentKey
]);
console
.
info
(
'
getExifDemo userComment:
'
+
JSON
.
stringify
(
userComment
));
}
else
{
console
.
error
(
'
getExif failed, message =
'
,
err
);
}
...
...
zh-cn/application-dev/reference/apis/js-apis-userFileManager.md
浏览文件 @
237303b7
...
...
@@ -1433,37 +1433,35 @@ getPhotoIndex(photoUri: string, albumUri: string, options: FetchOptions, callbac
import
dataSharePredicates
from
'
@ohos.data.dataSharePredicates
'
;
async
function
example
()
{
console
.
info
(
'
getPhotoIndexDemo
'
);
let
predicatesForGetAsset
=
new
dataSharePredicates
.
DataSharePredicates
();
let
fetchOp
=
{
fetchColumns
:
[],
predicates
:
predicatesForGetAsset
};
//Obtain the uri of the album
let
albumFetchResult
=
await
mgr
.
getAlbums
(
userFileManager
.
AlbumType
.
SYSTEM
,
userFileManager
.
AlbumSubtype
.
FAVORITE
,
fetchOp
);
let
album
=
await
albumFetchResult
.
getFirstObject
();
let
predicates
=
new
dataSharePredicates
.
DataSharePredicates
();
predicates
.
orderByAsc
(
"
add_modified
"
);
let
fetchOptions
=
{
fetchColumns
:
[],
predicates
:
predicates
};
let
photoFetchResult
=
await
album
.
getPhotoAssets
(
fetchOptions
);
let
expectIndex
=
1
;
//Obtain the uri of the second file
let
photoAsset
=
await
photoFetchResult
.
getPositionObject
(
expectIndex
);
mgr
.
getPhotoIndex
(
photoAsset
.
uri
,
album
.
albumUri
,
fetchOptions
,
(
err
,
index
)
=>
{
try
{
try
{
console
.
info
(
'
getPhotoIndexDemo
'
);
let
predicatesForGetAsset
=
new
dataSharePredicates
.
DataSharePredicates
();
let
fetchOp
=
{
fetchColumns
:
[],
predicates
:
predicatesForGetAsset
};
// Obtain the uri of the album
let
albumFetchResult
=
await
mgr
.
getAlbums
(
userFileManager
.
AlbumType
.
SYSTEM
,
userFileManager
.
AlbumSubType
.
FAVORITE
,
fetchOp
);
let
album
=
await
albumFetchResult
.
getFirstObject
();
let
predicates
=
new
dataSharePredicates
.
DataSharePredicates
();
predicates
.
orderByAsc
(
userFileManager
.
ImageVideoKey
.
DATE_MODIFIED
);
let
fetchOptions
=
{
fetchColumns
:
[
userFileManager
.
ImageVideoKey
.
DATE_MODIFIED
],
predicates
:
predicates
};
let
photoFetchResult
=
await
album
.
getPhotoAssets
(
fetchOptions
);
let
expectIndex
=
1
;
// Obtain the uri of the second file
let
photoAsset
=
await
photoFetchResult
.
getPositionObject
(
expectIndex
);
mgr
.
getPhotoIndex
(
photoAsset
.
uri
,
album
.
albumUri
,
fetchOptions
,
(
err
,
index
)
=>
{
if
(
err
==
undefined
)
{
console
.
info
(
`getPhotoIndex successfully and index is :
${
index
}
`
);
}
else
{
console
.
info
(
`getPhotoIndex failed;`
);
}
}
catch
(
error
)
{
console
.
info
(
`getPhotoIndex failed; error:
${
error
}
`
);
}
}
);
}
catch
(
error
)
{
console
.
info
(
`getPhotoIndex failed; error:
${
error
}
`
);
}
}
```
...
...
@@ -1508,33 +1506,34 @@ getPhotoIndex(photoUri: string, albumUri: string, options: FetchOptions): Promis
import
dataSharePredicates
from
'
@ohos.data.dataSharePredicates
'
;
async
function
example
()
{
console
.
info
(
'
getPhotoIndexDemo
'
);
let
predicatesForGetAsset
=
new
dataSharePredicates
.
DataSharePredicates
();
let
fetchOp
=
{
fetchColumns
:
[],
predicates
:
predicatesForGetAsset
};
//Obtain the uri of the album
let
albumFetchResult
=
await
mgr
.
getAlbums
(
userFileManager
.
AlbumType
.
SYSTEM
,
userFileManager
.
AlbumSubtype
.
FAVORITE
,
fetchOp
);
let
album
=
await
albumFetchResult
.
getFirstObject
();
let
predicates
=
new
dataSharePredicates
.
DataSharePredicates
();
predicates
.
orderByAsc
(
"
add_modified
"
);
let
fetchOptions
=
{
fetchColumns
:
[],
predicates
:
predicates
};
let
photoFetchResult
=
await
album
.
getPhotoAssets
(
fetchOptions
);
let
expectIndex
=
1
;
//Obtain the uri of the second file
let
photoAsset
=
await
photoFetchResult
.
getPositionObject
(
expectIndex
);
mgr
.
getPhotoIndex
(
photoAsset
.
uri
,
album
.
albumUri
,
fetchOptions
)
.
then
((
index
)
=>
{
console
.
info
(
`getPhotoIndex successfully and index is :
${
index
}
`
);
}).
catch
((
err
)
=>
{
try
{
console
.
info
(
'
getPhotoIndexDemo
'
);
let
predicatesForGetAsset
=
new
dataSharePredicates
.
DataSharePredicates
();
let
fetchOp
=
{
fetchColumns
:
[],
predicates
:
predicatesForGetAsset
};
// Obtain the uri of the album
let
albumFetchResult
=
await
mgr
.
getAlbums
(
userFileManager
.
AlbumType
.
SYSTEM
,
userFileManager
.
AlbumSubType
.
FAVORITE
,
fetchOp
);
let
album
=
await
albumFetchResult
.
getFirstObject
();
let
predicates
=
new
dataSharePredicates
.
DataSharePredicates
();
predicates
.
orderByAsc
(
userFileManager
.
ImageVideoKey
.
DATE_MODIFIED
);
let
fetchOptions
=
{
fetchColumns
:
[
userFileManager
.
ImageVideoKey
.
DATE_MODIFIED
],
predicates
:
predicates
};
let
photoFetchResult
=
await
album
.
getPhotoAssets
(
fetchOptions
);
let
expectIndex
=
1
;
// Obtain the uri of the second file
let
photoAsset
=
await
photoFetchResult
.
getPositionObject
(
expectIndex
);
mgr
.
getPhotoIndex
(
photoAsset
.
uri
,
album
.
albumUri
,
fetchOptions
).
then
((
index
)
=>
{
console
.
info
(
`getPhotoIndex successfully and index is :
${
index
}
`
);
}).
catch
((
err
)
=>
{
console
.
info
(
`getPhotoIndex failed; error:
${
err
}
`
);
})
});
}
catch
(
error
)
{
console
.
info
(
`getPhotoIndex failed; error:
${
error
}
`
);
}
}
```
...
...
@@ -2566,15 +2565,18 @@ async function example() {
try
{
console
.
info
(
'
getExifDemo
'
);
let
predicates
=
new
dataSharePredicates
.
DataSharePredicates
();
predicates
.
isNotNull
(
'
all_exif
'
)
let
fetchOptions
=
{
fetchColumns
:
[
'
all_exif
'
,
ImageVideoKey
.
USER_COMMENT
],
fetchColumns
:
[
'
all_exif
'
,
userFileManager
.
ImageVideoKey
.
USER_COMMENT
],
predicates
:
predicates
};
let
fetchResult
=
await
mgr
.
getPhotoAssets
(
fetchOptions
);
let
fileAsset
=
await
fetchResult
.
getFirstObject
();
console
.
info
(
'
getExifDemo fileAsset displayName:
'
+
JSON
.
stringify
(
fileAsset
.
displayName
));
let
exifMessage
=
await
fileAsset
.
getExif
();
let
userCommentKey
=
'
UserComment
'
;
let
userComment
=
JSON
.
stringify
(
JSON
.
parse
(
exifMessage
),
[
userCommentKey
]);
console
.
info
(
'
getExifDemo userComment:
'
+
JSON
.
stringify
(
userComment
));
fetchResult
.
close
();
}
catch
(
err
)
{
console
.
error
(
'
getExifDemoCallback failed with error:
'
+
err
);
...
...
@@ -2653,16 +2655,19 @@ async function example() {
try
{
console
.
info
(
'
getExifDemo
'
);
let
predicates
=
new
dataSharePredicates
.
DataSharePredicates
();
predicates
.
isNotNull
(
'
all_exif
'
)
let
fetchOptions
=
{
fetchColumns
:
[
'
all_exif
'
,
ImageVideoKey
.
USER_COMMENT
],
fetchColumns
:
[
'
all_exif
'
,
userFileManager
.
ImageVideoKey
.
USER_COMMENT
],
predicates
:
predicates
};
let
fetchResult
=
await
mgr
.
getPhotoAssets
(
fetchOptions
);
let
fileAsset
=
await
fetchResult
.
getFirstObject
();
console
.
info
(
'
getExifDemo fileAsset displayName:
'
+
JSON
.
stringify
(
fileAsset
.
displayName
));
let
userCommentKey
=
'
UserComment
'
;
fileAsset
.
getExif
((
err
,
exifMessage
)
=>
{
if
(
exifMessage
!=
undefined
)
{
let
userComment
=
JSON
.
stringify
(
JSON
.
parse
(
exifMessage
),
[
userCommentKey
]);
console
.
info
(
'
getExifDemo userComment:
'
+
JSON
.
stringify
(
userComment
));
}
else
{
console
.
error
(
'
getExif failed, message =
'
,
err
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录