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

!15172 Indent format modified for monthly

Merge pull request !15172 from 胡伟奇/monthly
......@@ -166,8 +166,8 @@ async function copySandbox2Public() {
1. 创建用于读写示例的文件。
```ts
async function example() {
```ts
async function example() {
let mediaType = mediaLibrary.MediaType.FILE;
let DIR_DOCUMENTS = mediaLibrary.DirectoryType.DIR_DOCUMENTS;
const context = getContext(this);
......@@ -178,8 +178,8 @@ async function copySandbox2Public() {
}).catch((err) => {
console.error("createAsset failed with error: " + err);
});
}
```
}
```
2. 使用open打开文件。
......
......@@ -63,8 +63,8 @@ let media = mediaLibrary.getMediaLibrary(context);
1. 在配置文件module.json5中声明权限。在配置文件的“module”标签内,增加“requestPermissions”标签,标签内容请根据实际情况填写。标签说明可参考[访问控制(权限)开发指导](../security/accesstoken-guidelines.md)
```json
{
```json
{
"module": {
"requestPermissions": [
{
......@@ -72,7 +72,7 @@ let media = mediaLibrary.getMediaLibrary(context);
"reason": "$string:reason",
"usedScene": {
"abilities": [
"MainAbility"
"EntryAbility"
],
"when": "always"
}
......@@ -82,7 +82,7 @@ let media = mediaLibrary.getMediaLibrary(context);
"reason": "$string:reason",
"usedScene": {
"abilities": [
"MainAbility"
"EntryAbility"
],
"when": "always"
}
......@@ -92,23 +92,23 @@ let media = mediaLibrary.getMediaLibrary(context);
"reason": "$string:reason",
"usedScene": {
"abilities": [
"MainAbility"
"EntryAbility"
],
"when": "always"
}
}
]
}
}
```
}
```
2. 在Ability.ts中onWindowStageCreate里调用requestPermissionsFromUser进行权限校验,可以选择需要动态申请获取的权限自行添加相应代码
```ts
import UIAbility from '@ohos.app.ability.UIAbility';
import abilityAccessCtrl, {Permissions} from '@ohos.abilityAccessCtrl';
```ts
import UIAbility from '@ohos.app.ability.UIAbility';
import abilityAccessCtrl, {Permissions} from '@ohos.abilityAccessCtrl';
export default class EntryAbility extends UIAbility {
export default class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage) {
let list : Array<Permissions> = ['ohos.permission.READ_MEDIA', 'ohos.permission.WRITE_MEDIA'];
let permissionRequestResult;
......@@ -117,11 +117,11 @@ let media = mediaLibrary.getMediaLibrary(context);
if (err) {
console.error('requestPermissionsFromUserError: ' + JSON.stringify(err));
} else {
permissionRequestResult=result;
permissionRequestResult = result;
console.info('permissionRequestResult: ' + JSON.stringify(permissionRequestResult));
}
});
}
}
```
}
```
......@@ -134,7 +134,6 @@ selectionArgs:'myAlbum',具体相册名称。
```ts
async function example() {
let fileKeyObj = mediaLibrary.FileKey;
let fileType = mediaLibrary.MediaType.IMAGE;
let option = {
selections: fileKeyObj.ALBUM_NAME + '= ?',
selectionArgs: ['myAlbum'],
......@@ -169,24 +168,24 @@ async function example() {
1. 建立检索条件,用于获取目的相册实例。
```ts
let fileKeyObj = mediaLibrary.FileKey;
let AlbumNoArgsFetchOp = {
```ts
let fileKeyObj = mediaLibrary.FileKey;
let AlbumNoArgsFetchOp = {
selections: fileKeyObj.ALBUM_NAME + '= ?',
selectionArgs: ['新建相册1']
}
```
}
```
2. 建立检索条件,用于获取目的相册下的视频资源。
```ts
let fileKeyObj = mediaLibrary.FileKey;
let videoType = mediaLibrary.MediaType.VIDEO;
let videoFetchOp = {
```ts
let fileKeyObj = mediaLibrary.FileKey;
let videoType = mediaLibrary.MediaType.VIDEO;
let videoFetchOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [videoType.toString()],
}
```
}
```
3. 通过Album.getFileAssets获取对应的资源。
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册