Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
77775f20
D
Docs
项目概览
OpenHarmony
/
Docs
大约 2 年 前同步成功
通知
161
Star
293
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看板
提交
77775f20
编写于
9月 05, 2023
作者:
A
Annie_wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update docs
Signed-off-by:
N
Annie_wang
<
annie.wangli@huawei.com
>
上级
ffacc4bf
变更
2
展开全部
显示空白变更内容
内联
并排
Showing
2 changed file
with
374 addition
and
467 deletion
+374
-467
en/application-dev/reference/apis/js-apis-photoAccessHelper.md
...plication-dev/reference/apis/js-apis-photoAccessHelper.md
+315
-413
en/application-dev/reference/apis/js-apis-userFileManager.md
en/application-dev/reference/apis/js-apis-userFileManager.md
+59
-54
未找到文件。
en/application-dev/reference/apis/js-apis-photoAccessHelper.md
浏览文件 @
77775f20
此差异已折叠。
点击以展开。
en/application-dev/reference/apis/js-apis-userFileManager.md
浏览文件 @
77775f20
...
@@ -1433,38 +1433,36 @@ For details about the error codes, see [Universal Error Codes](../errorcodes/err
...
@@ -1433,38 +1433,36 @@ For details about the error codes, see [Universal Error Codes](../errorcodes/err
import
dataSharePredicates
from
'
@ohos.data.dataSharePredicates
'
;
import
dataSharePredicates
from
'
@ohos.data.dataSharePredicates
'
;
async
function
example
()
{
async
function
example
()
{
try
{
console
.
info
(
'
getPhotoIndexDemo
'
);
console
.
info
(
'
getPhotoIndexDemo
'
);
let
predicatesForGetAsset
=
new
dataSharePredicates
.
DataSharePredicates
();
let
predicatesForGetAsset
=
new
dataSharePredicates
.
DataSharePredicates
();
let
fetchOp
=
{
let
fetchOp
=
{
fetchColumns
:
[],
fetchColumns
:
[],
predicates
:
predicatesForGetAsset
predicates
:
predicatesForGetAsset
};
};
//
Obtain the uri of the album
//
Obtain the uri of the album
let
albumFetchResult
=
await
mgr
.
getAlbums
(
userFileManager
.
AlbumType
.
SYSTEM
,
userFileManager
.
AlbumSubt
ype
.
FAVORITE
,
fetchOp
);
let
albumFetchResult
=
await
mgr
.
getAlbums
(
userFileManager
.
AlbumType
.
SYSTEM
,
userFileManager
.
AlbumSubT
ype
.
FAVORITE
,
fetchOp
);
let
album
=
await
albumFetchResult
.
getFirstObject
();
let
album
=
await
albumFetchResult
.
getFirstObject
();
let
predicates
=
new
dataSharePredicates
.
DataSharePredicates
();
let
predicates
=
new
dataSharePredicates
.
DataSharePredicates
();
predicates
.
orderByAsc
(
"
add_modified
"
);
predicates
.
orderByAsc
(
userFileManager
.
ImageVideoKey
.
DATE_MODIFIED
);
let
fetchOptions
=
{
let
fetchOptions
=
{
fetchColumns
:
[
],
fetchColumns
:
[
userFileManager
.
ImageVideoKey
.
DATE_MODIFIED
],
predicates
:
predicates
predicates
:
predicates
};
};
let
photoFetchResult
=
await
album
.
getPhotoAssets
(
fetchOptions
);
let
photoFetchResult
=
await
album
.
getPhotoAssets
(
fetchOptions
);
let
expectIndex
=
1
;
let
expectIndex
=
1
;
//
Obtain the uri of the second file
//
Obtain the uri of the second file
let
photoAsset
=
await
photoFetchResult
.
getPositionObject
(
expectIndex
);
let
photoAsset
=
await
photoFetchResult
.
getPositionObject
(
expectIndex
);
mgr
.
getPhotoIndex
(
photoAsset
.
uri
,
album
.
albumUri
,
fetchOptions
,
(
err
,
index
)
=>
{
mgr
.
getPhotoIndex
(
photoAsset
.
uri
,
album
.
albumUri
,
fetchOptions
,
(
err
,
index
)
=>
{
try
{
if
(
err
==
undefined
)
{
if
(
err
==
undefined
)
{
console
.
info
(
`getPhotoIndex successfully and index is :
${
index
}
`
);
console
.
info
(
`getPhotoIndex successfully and index is :
${
index
}
`
);
}
else
{
}
else
{
console
.
info
(
`getPhotoIndex failed;`
);
console
.
info
(
`getPhotoIndex failed;`
);
}
}
});
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
info
(
`getPhotoIndex failed; error:
${
error
}
`
);
console
.
info
(
`getPhotoIndex failed; error:
${
error
}
`
);
}
}
}
}
}
```
```
...
@@ -1508,33 +1506,34 @@ For details about the error codes, see [Universal Error Codes](../errorcodes/err
...
@@ -1508,33 +1506,34 @@ For details about the error codes, see [Universal Error Codes](../errorcodes/err
import
dataSharePredicates
from
'
@ohos.data.dataSharePredicates
'
;
import
dataSharePredicates
from
'
@ohos.data.dataSharePredicates
'
;
async
function
example
()
{
async
function
example
()
{
try
{
console
.
info
(
'
getPhotoIndexDemo
'
);
console
.
info
(
'
getPhotoIndexDemo
'
);
let
predicatesForGetAsset
=
new
dataSharePredicates
.
DataSharePredicates
();
let
predicatesForGetAsset
=
new
dataSharePredicates
.
DataSharePredicates
();
let
fetchOp
=
{
let
fetchOp
=
{
fetchColumns
:
[],
fetchColumns
:
[],
predicates
:
predicatesForGetAsset
predicates
:
predicatesForGetAsset
};
};
//
Obtain the uri of the album
//
Obtain the uri of the album
let
albumFetchResult
=
await
mgr
.
getAlbums
(
userFileManager
.
AlbumType
.
SYSTEM
,
userFileManager
.
AlbumSubt
ype
.
FAVORITE
,
fetchOp
);
let
albumFetchResult
=
await
mgr
.
getAlbums
(
userFileManager
.
AlbumType
.
SYSTEM
,
userFileManager
.
AlbumSubT
ype
.
FAVORITE
,
fetchOp
);
let
album
=
await
albumFetchResult
.
getFirstObject
();
let
album
=
await
albumFetchResult
.
getFirstObject
();
let
predicates
=
new
dataSharePredicates
.
DataSharePredicates
();
let
predicates
=
new
dataSharePredicates
.
DataSharePredicates
();
predicates
.
orderByAsc
(
"
add_modified
"
);
predicates
.
orderByAsc
(
userFileManager
.
ImageVideoKey
.
DATE_MODIFIED
);
let
fetchOptions
=
{
let
fetchOptions
=
{
fetchColumns
:
[
],
fetchColumns
:
[
userFileManager
.
ImageVideoKey
.
DATE_MODIFIED
],
predicates
:
predicates
predicates
:
predicates
};
};
let
photoFetchResult
=
await
album
.
getPhotoAssets
(
fetchOptions
);
let
photoFetchResult
=
await
album
.
getPhotoAssets
(
fetchOptions
);
let
expectIndex
=
1
;
let
expectIndex
=
1
;
//
Obtain the uri of the second file
//
Obtain the uri of the second file
let
photoAsset
=
await
photoFetchResult
.
getPositionObject
(
expectIndex
);
let
photoAsset
=
await
photoFetchResult
.
getPositionObject
(
expectIndex
);
mgr
.
getPhotoIndex
(
photoAsset
.
uri
,
album
.
albumUri
,
fetchOptions
).
then
((
index
)
=>
{
mgr
.
getPhotoIndex
(
photoAsset
.
uri
,
album
.
albumUri
,
fetchOptions
)
.
then
((
index
)
=>
{
console
.
info
(
`getPhotoIndex successfully and index is :
${
index
}
`
);
console
.
info
(
`getPhotoIndex successfully and index is :
${
index
}
`
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
info
(
`getPhotoIndex failed; error:
${
err
}
`
);
console
.
info
(
`getPhotoIndex failed; error:
${
err
}
`
);
})
});
}
catch
(
error
)
{
console
.
info
(
`getPhotoIndex failed; error:
${
error
}
`
);
}
}
}
```
```
...
@@ -2565,15 +2564,18 @@ async function example() {
...
@@ -2565,15 +2564,18 @@ async function example() {
try
{
try
{
console
.
info
(
'
getExifDemo
'
);
console
.
info
(
'
getExifDemo
'
);
let
predicates
=
new
dataSharePredicates
.
DataSharePredicates
();
let
predicates
=
new
dataSharePredicates
.
DataSharePredicates
();
predicates
.
isNotNull
(
'
all_exif
'
)
let
fetchOptions
=
{
let
fetchOptions
=
{
fetchColumns
:
[
'
all_exif
'
,
ImageVideoKey
.
USER_COMMENT
],
fetchColumns
:
[
'
all_exif
'
,
userFileManager
.
ImageVideoKey
.
USER_COMMENT
],
predicates
:
predicates
predicates
:
predicates
};
};
let
fetchResult
=
await
mgr
.
getPhotoAssets
(
fetchOptions
);
let
fetchResult
=
await
mgr
.
getPhotoAssets
(
fetchOptions
);
let
fileAsset
=
await
fetchResult
.
getFirstObject
();
let
fileAsset
=
await
fetchResult
.
getFirstObject
();
console
.
info
(
'
getExifDemo fileAsset displayName:
'
+
JSON
.
stringify
(
fileAsset
.
displayName
));
let
exifMessage
=
await
fileAsset
.
getExif
();
let
exifMessage
=
await
fileAsset
.
getExif
();
let
userCommentKey
=
'
UserComment
'
;
let
userCommentKey
=
'
UserComment
'
;
let
userComment
=
JSON
.
stringify
(
JSON
.
parse
(
exifMessage
),
[
userCommentKey
]);
let
userComment
=
JSON
.
stringify
(
JSON
.
parse
(
exifMessage
),
[
userCommentKey
]);
console
.
info
(
'
getExifDemo userComment:
'
+
JSON
.
stringify
(
userComment
));
fetchResult
.
close
();
fetchResult
.
close
();
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
'
getExifDemoCallback failed with error:
'
+
err
);
console
.
error
(
'
getExifDemoCallback failed with error:
'
+
err
);
...
@@ -2651,16 +2653,19 @@ async function example() {
...
@@ -2651,16 +2653,19 @@ async function example() {
try
{
try
{
console
.
info
(
'
getExifDemo
'
);
console
.
info
(
'
getExifDemo
'
);
let
predicates
=
new
dataSharePredicates
.
DataSharePredicates
();
let
predicates
=
new
dataSharePredicates
.
DataSharePredicates
();
predicates
.
isNotNull
(
'
all_exif
'
)
let
fetchOptions
=
{
let
fetchOptions
=
{
fetchColumns
:
[
'
all_exif
'
,
ImageVideoKey
.
USER_COMMENT
],
fetchColumns
:
[
'
all_exif
'
,
userFileManager
.
ImageVideoKey
.
USER_COMMENT
],
predicates
:
predicates
predicates
:
predicates
};
};
let
fetchResult
=
await
mgr
.
getPhotoAssets
(
fetchOptions
);
let
fetchResult
=
await
mgr
.
getPhotoAssets
(
fetchOptions
);
let
fileAsset
=
await
fetchResult
.
getFirstObject
();
let
fileAsset
=
await
fetchResult
.
getFirstObject
();
console
.
info
(
'
getExifDemo fileAsset displayName:
'
+
JSON
.
stringify
(
fileAsset
.
displayName
));
let
userCommentKey
=
'
UserComment
'
;
let
userCommentKey
=
'
UserComment
'
;
fileAsset
.
getExif
((
err
,
exifMessage
)
=>
{
fileAsset
.
getExif
((
err
,
exifMessage
)
=>
{
if
(
exifMessage
!=
undefined
)
{
if
(
exifMessage
!=
undefined
)
{
let
userComment
=
JSON
.
stringify
(
JSON
.
parse
(
exifMessage
),
[
userCommentKey
]);
let
userComment
=
JSON
.
stringify
(
JSON
.
parse
(
exifMessage
),
[
userCommentKey
]);
console
.
info
(
'
getExifDemo userComment:
'
+
JSON
.
stringify
(
userComment
));
}
else
{
}
else
{
console
.
error
(
'
getExif failed, message =
'
,
err
);
console
.
error
(
'
getExif failed, message =
'
,
err
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录