diff --git a/zh-cn/application-dev/reference/apis/js-apis-fileio.md b/zh-cn/application-dev/reference/apis/js-apis-fileio.md index 36bc2e261e82c3b000d40cb466f54626ff838dec..a09553121fc9f07f7ce95854c3ef77d1294ba6c1 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-fileio.md +++ b/zh-cn/application-dev/reference/apis/js-apis-fileio.md @@ -1532,10 +1532,10 @@ rename(oldPath: string, newPath: string): Promise<void> **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | ------- | ------ | ---- | ------------ | - | oldPath | string | 是 | 目标文件的当前绝对路径。 | - | Newpath | String | 是 | 目标文件的新绝对路径。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------- | ------ | ---- | ------------------------ | + | oldPath | string | 是 | 目标文件的当前绝对路径。 | + | newPath | String | 是 | 目标文件的新绝对路径。 | - 返回值: | 类型 | 说明 | @@ -1544,7 +1544,7 @@ rename(oldPath: string, newPath: string): Promise<void> - 示例: ```js - fileio.rename(oldPath, Newpath).then(function() { + fileio.rename(oldPath, newPath).then(function() { console.info("rename successfully"); }).catch(function(err){ console.info("rename failed with error:"+ err); @@ -1563,13 +1563,13 @@ rename(oldPath: string, newPath: string, callback: AsyncCallback<void>): v - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | ------------- | - | oldpath | string | 是 | 目标文件的当前绝对路径。 | - | Newpath | String | 是 | 目标文件的新绝对路径。 | + | oldPath | string | 是 | 目标文件的当前绝对路径。 | + | newPath | String | 是 | 目标文件的新绝对路径。 | | Callback | AsyncCallback<void> | 是 | 异步重命名文件之后的回调。 | - 示例: ```js - fileio.rename(oldpath, Newpath, function(err){ + fileio.rename(oldPath, newPath, function(err){ }); ``` @@ -1586,11 +1586,11 @@ renameSync(oldPath: string, newPath: string): void | 参数名 | 类型 | 必填 | 说明 | | ------- | ------ | ---- | ------------ | | oldPath | string | 是 | 目标文件的当前绝对路径。 | - | Newpath | String | 是 | 目标文件的新绝对路径。 | + | newPath | String | 是 | 目标文件的新绝对路径。 | - 示例: ```js - fileio.renameSync(oldpath, newpath); + fileio.renameSync(oldPath, newPath); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-filemanager.md b/zh-cn/application-dev/reference/apis/js-apis-filemanager.md index 43ab0d49f446b8c94edeb457800dd44cf86e338f..581823d3df733bbe829c68bdad574dc2cfd7ffb7 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-filemanager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-filemanager.md @@ -21,7 +21,7 @@ getRoot(options? : {dev? : DevInfo}) : Promise<FileInfo[]> - 参数 | 参数名 | 类型 | 必填 | 说明 | | --- | --- | --- | -- | - | dev | [DevInfo](#devinfo) | 否 | 设备名, 不填为默认值dev = {name: "local"}, 当前仅支持设备'local' | + | options | Object | 否 | 支持如下选项:
- dev,[DevInfo](#devinfo)类型,不填默认dev = {name: "local"}, 当前仅支持设备'local' | - 返回值 @@ -31,17 +31,17 @@ getRoot(options? : {dev? : DevInfo}) : Promise<FileInfo[]> - 示例 -```js -filemanager.getRoot().then((fileInfo) => { - if(Array.isArray(fileInfo)) { - for (var i = 0; i < fileInfo.length; i++) { - console.log(JSON.Stringify(fileInfo)) - } - } -}).catch((err) => { - console.log(err) -}); -``` + ```js + filemanager.getRoot().then((fileInfo) => { + if(Array.isArray(fileInfo)) { + for (var i = 0; i < fileInfo.length; i++) { + console.log(JSON.Stringify(fileInfo)) + } + } + }).catch((err) => { + console.log(err) + }); + ``` ## filemanager.getRoot @@ -55,20 +55,20 @@ getRoot(options? : {dev? : DevInfo}, callback : AsyncCallback<FileInfo[]>) | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | ----------------------------- | - | dev | [DevInfo](#devinfo) | 否 | 设备名, 不填为默认值dev = {name: "local"}, 当前仅支持设备'local' | + | options | Object | 否 | 支持如下选项:
- dev,[DevInfo](#devinfo)类型,不填默认dev = {name: "local"}, 当前仅支持设备'local' | | callback | AsyncCallback<[FileInfo](#fileinfo)[]> | 是 | 异步获取文件的信息之后的回调 | - 示例 -```js -filemanager.getRoot((err, fileInfo) => { - if(Array.isArray(fileInfo)) { - for (var i = 0; i < fileInfo.length; i++) { - console.log(JSON.Stringify(fileInfo)) - } - } -}) -``` + ```js + filemanager.getRoot((err, fileInfo) => { + if(Array.isArray(fileInfo)) { + for (var i = 0; i < fileInfo.length; i++) { + console.log(JSON.Stringify(fileInfo)) + } + } + }); + ``` ## filemanager.listFile @@ -81,12 +81,10 @@ listFile(path : string, type : string, options? : {dev? : DevInfo, offset? : num - 参数 | 参数名 | 类型 | 必填 | 说明 | | --- | --- | --- | -- | - | type | string | 是 | 待查询文件类型, 支持以下类型 "file", "image", "audio", "video" | | path | string | 是 | 待查询目录uri | - | dev | [DevInfo](#devinfo) | 是 | 设备名, 不填为默认值dev = {name: "local"}, 当前仅支持设备'local' | - | offset | number | 否 | 待查询文件偏移 | - | count | number | 否 | 待查询文件个数 | - + | type | string | 是 | 待查询文件类型, 支持以下类型 "file", "image", "audio", "video" | + | options | Object | 否 | 支持如下选项:
- dev,[DevInfo](#devinfo)类型,不填默认dev = {name: "local"}, 当前仅支持设备'local'。
- offset,number类型,待查询文件偏移个数。
- count,number类型,待查询文件个数。 | + - 返回值 | 类型 | 说明 | @@ -100,21 +98,24 @@ listFile(path : string, type : string, options? : {dev? : DevInfo, offset? : num | 获取FMS服务失败 | No such process | 3 | 获取FMS服务失败 | | path对应uri不是相册、目录 | Not a directory | 20 | path对应uri不是相册、目录 | -```js -// 获取目录下所有文件 -// 通过listFile、getRoot获取的文件uri -let media_path = file.uri -filemanager.listFile(media_path, "file") -.then((fileInfo) => { - if(Array.isArray(fileInfo)) { - for (var i = 0; i < fileInfo.length; i++) { - console.log(JSON.Stringify(fileInfo)) - } - } -}).catch((err) => { - console.log(err) -}) -``` +- 示例 + + ```js + // 获取目录下所有文件 + // 通过listFile、getRoot获取的文件uri + let media_path = file.uri + filemanager.listFile(media_path, "file") + .then((fileInfo) => { + if(Array.isArray(fileInfo)) { + for (var i = 0; i < fileInfo.length; i++) { + console.log(JSON.Stringify(fileInfo)) + } + } + }).catch((err) => { + console.log(err) + }); + ``` + ## filemanager.listFile listFile(path : string, type : string, options? : {dev? : DevInfo, offset? : number, count? : number}, callback : AsyncCallback<FileInfo[]>) : void @@ -127,11 +128,9 @@ listFile(path : string, type : string, options? : {dev? : DevInfo, offset? : num | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | ------------------------------------------------------------ | - | type | string | 是 | 待查询文件类型, 支持以下类型 "file", "image", "audio", "video" | | path | string | 是 | 待查询目录uri | - | dev | [DevInfo](#devinfo) | 否 | 设备名, 不填为默认值dev = {name: "local"}, 当前仅支持设备'local' | - | offset | number | 否 | 待查询文件偏移 | - | count | number | 否 | 待查询文件个数 | + | type | string | 是 | 待查询文件类型, 支持以下类型 "file", "image", "audio", "video" | + | options | Object | 否 | 支持如下选项:
- dev,[DevInfo](#devinfo)类型,不填默认dev = {name: "local"}, 当前仅支持设备'local'。
- offset,number类型,待查询文件偏移个数。
- count,number类型,待查询文件个数。 | | callback | AsyncCallback<[FileInfo](#fileinfo)[]> | 是 | 异步获取文件的信息之后的回调 | - 异常 @@ -141,21 +140,23 @@ listFile(path : string, type : string, options? : {dev? : DevInfo, offset? : num | 获取FMS服务失败 | No such process | 3 | 获取FMS服务失败 | | path对应uri不是相册、目录 | Not a directory | 20 | path对应uri不是相册、目录 | -```js -// 通过listFile、getRoot获取的文件uri -let media_path = file.uri -filemanager.listFile(media_path, "file", (err, fileInfo) => { - if(Array.isArray(fileInfo)) { - for (var i = 0; i < fileInfo.length; i++) { - console.log(JSON.Stringify(fileInfo)) - } - } -}) -``` +- 示例 + + ```js + // 通过listFile、getRoot获取的文件uri + let media_path = file.uri + filemanager.listFile(media_path, "file", (err, fileInfo) => { + if(Array.isArray(fileInfo)) { + for (var i = 0; i < fileInfo.length; i++) { + console.log(JSON.Stringify(fileInfo)) + } + } + }); + ``` ## filemanager.createFile -filemanager.createFile(path : string, filename : string, options? : {dev? : DevInfo}) : promise<string> +filemanager.createFile(path : string, filename : string, options? : {dev? : DevInfo}) : Promise<string> 以异步方法创建文件到指定路径,返回文件uri。使用promise形式返回结果。 @@ -166,7 +167,7 @@ filemanager.createFile(path : string, filename : string, options? : {dev? : DevI | --- | --- | --- | -- | | filename | string | 是 | 待创建的文件名 | | path | string | 是 | 待保存目的相册uri | - | dev | [DevInfo](#devinfo) | 否 | 设备名, 不填为默认值dev = {name: "local"}, 当前仅支持设备'local' | + | options | Object | 否 | 支持如下选项:
- dev,[DevInfo](#devinfo)类型,不填默认dev = {name: "local"}, 当前仅支持设备'local' | - 返回值 @@ -182,18 +183,20 @@ filemanager.createFile(path : string, filename : string, options? : {dev? : DevI | 获取FMS服务失败 | No such process | 3 | 获取FMS服务失败 | | path对应uri不是相册、目录 | Not a directory | 20 | path对应uri不是相册、目录 | -```js -// 创建文件,返回文件uri -let media_path = file.uri // 通过listFile、getRoot获取的文件uri -let name = "xxx.jpg" // 待保存文件的后缀 -filemanager.createFile(media_path, name) -.then((uri) => { -// 返回uri给应用 -}) -.catch((err) => { - console.log(err) -}) -``` +- 示例 + + ```js + // 创建文件,返回文件uri + let media_path = file.uri // 通过listFile、getRoot获取的文件uri + let name = "xxx.jpg" // 待保存文件的后缀 + filemanager.createFile(media_path, name) + .then((uri) => { + // 返回uri给应用 + }) + .catch((err) => { + console.log(err) + }); + ``` ## filemanager.createFile @@ -209,7 +212,7 @@ createFile(path : string, filename: string, options? : {dev? : DevInfo}, callbac | -------- | ------------------------- | ---- | ----------------------------- | | filename | string | 是 | 待创建的文件名 | | path | string | 是 | 待保存目的相册uri | - | dev | [DevInfo](#devinfo) | 否 | 设备名, 不填为默认值dev = {name: "local"}, 当前仅支持设备'local' | + | options | Object | 否 | 支持如下选项:
- dev,[DevInfo](#devinfo)类型,不填默认dev = {name: "local"}, 当前仅支持设备'local' | | callback | AsyncCallback<[FileInfo](#fileinfo)[]> | 是 | 异步获取文件的信息之后的回调 | - 异常 @@ -221,16 +224,18 @@ createFile(path : string, filename: string, options? : {dev? : DevInfo}, callbac | 获取FMS服务失败 | No such process | 3 | 获取FMS服务失败 | | path对应uri不是相册、目录 | Not a directory | 20 | path对应uri不是相册、目录 | -```js -// 创建文件,返回文件uri -// 通过listFile、getRoot获取的文件uri -let media_path = file.uri -// 待保存文件的后缀 -let name = "xxx.jpg" -filemanager.createFile(media_path, name, (err, uri) => { -// 返回uri给应用 -}) -``` +- 示例 + + ```js + // 创建文件,返回文件uri + // 通过listFile、getRoot获取的文件uri + let media_path = file.uri + // 待保存文件的后缀 + let name = "xxx.jpg" + filemanager.createFile(media_path, name, (err, uri) => { + // 返回uri给应用 + }); + ``` ## FileInfo 文件信息类型,通过getRoot, listFile等接口返回的类型。 @@ -249,12 +254,13 @@ filemanager.createFile(media_path, name, (err, uri) => { | modifiedTime | number | 是 | 否 | 媒体修改时间 | ## DevInfo + 设备类型,配置接口访问的设备类型。 **系统能力**:以下各项对应的系统能力均为SystemCapability.FileManagement.FileManagerService。 ### 属性 - | 参数名 | 类型 | 可读 | 可写 | 说明 | - | --- | -- | -- | -- | -- | - | name | string | 是 | 是 | 设备名称 | \ No newline at end of file +| 参数名 | 类型 | 可读 | 可写 | 说明 | +| ------ | ------ | ---- | ---- | -------- | +| name | string | 是 | 是 | 设备名称 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-volumemanager.md b/zh-cn/application-dev/reference/apis/js-apis-volumemanager.md index c644344a1efaacae2939a6828fa27714b1a56c1a..672f77b8de7c906156d4987453c4341df1baa671 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-volumemanager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-volumemanager.md @@ -2,8 +2,8 @@ > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > -> - 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 -> - 此接口为系统接口,三方应用不支持调用。 +> - 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> - 本模块接口为系统接口,三方应用不支持调用。 ## 导入模块 @@ -11,7 +11,7 @@ import volumemanager from "@ohos.volumeManager"; ``` -## volumemanager.getAllVolumes9+ +## volumemanager.getAllVolumes getAllVolumes(): Promise<Array<Volume>> @@ -57,7 +57,7 @@ getAllVolumes(callback: AsyncCallback<Array<Volume>>): void ``` -## volumemanager.mount9+ +## volumemanager.mount mount(volumeId: string): Promise<boolean> @@ -86,7 +86,7 @@ mount(volumeId: string): Promise<boolean> }); ``` -## volumemanager.mount9+ +## volumemanager.mount mount(volumeId: string, callback:AsyncCallback<boolean>):void @@ -110,7 +110,7 @@ mount(volumeId: string, callback:AsyncCallback<boolean>):void }); ``` -## volumemanager.unmount9+ +## volumemanager.unmount unmount(volumeId: string): Promise<boolean> @@ -139,7 +139,7 @@ unmount(volumeId: string): Promise<boolean> }); ``` -## volumemanager.unmount9+ +## volumemanager.unmount unmount(volumeId: string, callback:AsyncCallback<boolean>):void @@ -163,7 +163,7 @@ unmount(volumeId: string, callback:AsyncCallback<boolean>):void }); ``` -## Volume9+ +## Volume **系统能力**:以下各项对应的系统能力均为SystemCapability.FileManagement.StorageService.Volume。