提交 f129a1cd 编写于 作者: L lvyuanyuan

媒体库uri修改为file类型

Signed-off-by: Nlvyuanyuan <lvyuanyuan7@huawei.com>
Change-Id: I3180daa39474f95c1506a2d296a733703882c7e2
上级 c17e9246
......@@ -128,7 +128,7 @@ For details about the APIs, see [User File Access and Management](../reference/a
// Create a file.
// sourceUri is the URI in fileinfo of the Download directory.
// You need to use the obtained URI for development.
let sourceUri = "datashare:///media/file/6";
let sourceUri = "file://media/file/6";
let displayName = "file1";
let fileUri = null;
try {
......
......@@ -654,7 +654,7 @@ For details about error codes, see [File Management Error Codes](../errorcodes/e
// The media library URI is used as an example.
// In the sample code, sourceUri indicates the Download directory. The URI is the URI in fileInfo.
// You can use the URI obtained.
let sourceUri = "datashare:///media/file/6";
let sourceUri = "file://media/file/6";
let displayName = "file1"
let fileUri = null;
try {
......@@ -698,7 +698,7 @@ For details about error codes, see [File Management Error Codes](../errorcodes/e
// The media library URI is used as an example.
// In the sample code, sourceUri indicates the Download directory. The URI is the URI in fileInfo.
// You can use the URI obtained.
let sourceUri = "datashare:///media/file/6";
let sourceUri = "file://media/file/6";
let displayName = "file1"
try {
// Obtain fileAccessHelper by referring to the sample code of fileAccess.createFileAccessHelper.
......@@ -747,7 +747,7 @@ For details about error codes, see [File Management Error Codes](../errorcodes/e
// The media library URI is used as an example.
// In the sample code, sourceUri indicates the Download directory. The URI is the URI in fileInfo.
// You can use the URI obtained.
let sourceUri = "datashare:///media/file/6";
let sourceUri = "file://media/file/6";
let dirName = "dirTest"
let dirUri = null;
try {
......@@ -791,7 +791,7 @@ For details about error codes, see [File Management Error Codes](../errorcodes/e
// The media library URI is used as an example.
// In the sample code, sourceUri indicates the Download directory. The URI is the URI in fileInfo.
// You can use the URI obtained.
let sourceUri = "datashare:///media/file/6";
let sourceUri = "file://media/file/6";
let dirName = "dirTest"
try {
// Obtain fileAccessHelper by referring to the sample code of fileAccess.createFileAccessHelper.
......@@ -840,7 +840,7 @@ For details about error codes, see [File Management Error Codes](../errorcodes/e
// The media library URI is used as an example.
// In the sample code, targetUri indicates a file in the Download directory. The URI is the URI in fileInfo.
// You can use the URI obtained.
let targetUri = "datashare:///media/file/100";
let targetUri = "file://media/file/100";
try {
// Obtain fileAccessHelper by referring to the sample code of fileAccess.createFileAccessHelper.
let fd = await fileAccessHelper.openFile(targetUri, fileAccess.OPENFLAGS.READ);
......@@ -877,7 +877,7 @@ For details about error codes, see [File Management Error Codes](../errorcodes/e
// The media library URI is used as an example.
// In the sample code, targetUri indicates a file in the Download directory. The URI is the URI in fileInfo.
// You can use the URI obtained.
let targetUri = "datashare:///media/file/100";
let targetUri = "file://media/file/100";
try {
// Obtain fileAccessHelper by referring to the sample code of fileAccess.createFileAccessHelper.
fileAccessHelper.openFile(targetUri, fileAccess.OPENFLAGS.READ, function (err, fd) {
......@@ -924,7 +924,7 @@ For details about error codes, see [File Management Error Codes](../errorcodes/e
// The media library URI is used as an example.
// In the sample code, targetUri indicates a file in the Download directory. The URI is the URI in fileInfo.
// You can use the URI obtained.
let targetUri = "datashare:///media/file/100";
let targetUri = "file://media/file/100";
try {
// Obtain fileAccessHelper by referring to the sample code of fileAccess.createFileAccessHelper.
let code = await fileAccessHelper.delete(targetUri);
......@@ -962,7 +962,7 @@ For details about error codes, see [File Management Error Codes](../errorcodes/e
// The media library URI is used as an example.
// In the sample code, targetUri indicates a file in the Download directory. The URI is the URI in fileInfo.
// You can use the URI obtained.
let targetUri = "datashare:///media/file/100";
let targetUri = "file://media/file/100";
try {
// Obtain fileAccessHelper by referring to the sample code of fileAccess.createFileAccessHelper.
fileAccessHelper.delete(targetUri, function (err, code) {
......@@ -1010,8 +1010,8 @@ For details about error codes, see [File Management Error Codes](../errorcodes/e
// The media library URI is used as an example.
// In the sample code, sourceFile destFile indicates the file or directory in the Download directory. The URI is the URI in fileInfo.
// You can use the URI obtained.
let sourceFile = "datashare:///media/file/102";
let destFile = "datashare:///media/file/101";
let sourceFile = "file://media/file/102";
let destFile = "file://media/file/101";
try {
// Obtain fileAccessHelper by referring to the sample code of fileAccess.createFileAccessHelper.
let fileUri = await fileAccessHelper.move(sourceFile, destFile);
......@@ -1049,8 +1049,8 @@ For details about error codes, see [File Management Error Codes](../errorcodes/e
// The media library URI is used as an example.
// In the sample code, sourceFile destFile indicates the file or directory in the Download directory. The URI is the URI in fileInfo.
// You can use the URI obtained.
let sourceFile = "datashare:///media/file/102";
let destFile = "datashare:///media/file/101";
let sourceFile = "file://media/file/102";
let destFile = "file://media/file/101";
try {
// Obtain fileAccessHelper by referring to the sample code of fileAccess.createFileAccessHelper.
fileAccessHelper.move(sourceFile, destFile, function (err, fileUri) {
......@@ -1098,7 +1098,7 @@ For details about error codes, see [File Management Error Codes](../errorcodes/e
// The media library URI is used as an example.
// In the sample code, sourceDir indicates a file in the Download directory. The URI is the URI in fileInfo.
// You can use the URI obtained.
let sourceDir = "datashare:///media/file/100";
let sourceDir = "file://media/file/100";
try {
// Obtain fileAccessHelper by referring to the sample code of fileAccess.createFileAccessHelper.
let DestDir = await fileAccessHelper.rename(sourceDir, "testDir");
......@@ -1136,7 +1136,7 @@ For details about error codes, see [File Management Error Codes](../errorcodes/e
// The media library URI is used as an example.
// In the sample code, sourceDir indicates a file in the Download directory. The URI is the URI in fileInfo.
// You can use the URI obtained.
let sourceDir = "datashare:///media/file/100";
let sourceDir = "file://media/file/100";
try {
// Obtain fileAccessHelper by referring to the sample code of fileAccess.createFileAccessHelper.
fileAccessHelper.rename(sourceDir, "testDir", function (err, DestDir) {
......@@ -1183,7 +1183,7 @@ For details about error codes, see [File Management Error Codes](../errorcodes/e
// The media library URI is used as an example.
// In the sample code, sourceDir indicates a file in the Download directory. The URI is the URI in fileInfo.
// You can use the URI obtained.
let sourceDir = "datashare:///media/file/100";
let sourceDir = "file://media/file/100";
try {
// Obtain fileAccessHelper by referring to the sample code of fileAccess.createFileAccessHelper.
let existJudgment = await fileAccessHelper.access(sourceDir);
......@@ -1223,7 +1223,7 @@ For details about error codes, see [File Management Error Codes](../errorcodes/e
// The media library URI is used as an example.
// In the sample code, sourceDir indicates a file in the Download directory. The URI is the URI in fileInfo.
// You can use the URI obtained.
let sourceDir = "datashare:///media/file/100";
let sourceDir = "file://media/file/100";
try {
// Obtain fileAccessHelper by referring to the sample code of fileAccess.createFileAccessHelper.
fileAccessHelper.access(sourceDir, function (err, existJudgment) {
......@@ -1269,7 +1269,7 @@ Obtains a **FileInfo** object based on the specified URI. This API uses a promis
// The media library URI is used as an example.
// In the sample code, sourceUri indicates the Download directory. The URI is the URI in fileInfo.
// You can use the URI obtained.
let sourceUri = "datashare:///media/file/6";
let sourceUri = "file://media/file/6";
try {
// Obtain fileAccessHelper by referring to the sample code of fileAccess.createFileAccessHelper.
let fileInfo = await fileAccessHelper.getFileInfoFromUri(sourceUri);
......@@ -1301,7 +1301,7 @@ Obtains a **FileInfo** object based on the specified URI. This API uses an async
// The media library URI is used as an example.
// In the sample code, sourceUri indicates the Download directory. The URI is the URI in fileInfo.
// You can use the URI obtained.
let sourceUri = "datashare:///media/file/6";
let sourceUri = "file://media/file/6";
try {
// Obtain fileAccessHelper by referring to the sample code of fileAccess.createFileAccessHelper.
fileAccessHelper.getFileInfoFromUri(sourceUri, function (err, fileInfo) {
......@@ -1421,7 +1421,7 @@ Obtains the **Pixelmap** object of a media file based on the specified URI and s
// The media library URI is used as an example.
// In the sample code, targetUri indicates a media file (image, audio, or video) in the Download directory. The URI is the URI in fileInfo.
// You can use the URI obtained.
let targetUri = "datashare:///media/image/100";
let targetUri = "file://media/image/100";
let size = { width: 128, height: 128 };
try {
// Obtain fileAccessHelper by referring to the sample code of fileAccess.createFileAccessHelper.
......@@ -1458,7 +1458,7 @@ Obtains the **Pixelmap** object of a media file based on the specified URI and s
// The media library URI is used as an example.
// In the sample code, targetUri indicates a media file (image, audio, or video) in the Download directory. The URI is the URI in fileInfo.
// You can use the URI obtained.
let targetUri = "datashare:///media/image/100";
let targetUri = "file://media/image/100";
let size = { width: 128, height: 128 };
try {
// Obtain fileAccessHelper by referring to the sample code of fileAccess.createFileAccessHelper.
......@@ -1566,8 +1566,8 @@ Copies a file or directory. This API uses a promise to return the result.
| Name | Type | Mandatory| Description |
| --------- | ------- | ---- | ------------------------------------------------------------ |
| sourceUri | string | Yes | URI of the file or directory to copy, for example, **datashare:///media/file/102**. |
| destUri | string | Yes | URI of the destination directory, for example, **datashare:///media/file/101**. |
| sourceUri | string | Yes | URI of the file or directory to copy, for example, **file://media/file/102**. |
| destUri | string | Yes | URI of the destination directory, for example, **file://media/file/101**. |
| force | boolean | No | Whether to forcibly overwrite the file with the same name. <br>If **force** is **true**, the file with the same name will be overwritten. If **force** is **false** or not specified, the file with the same name will not be overwritten.|
**Return value**
......@@ -1582,8 +1582,8 @@ Example 1: Copy a file with **force** unspecified.
// The media library URI is used as an example.
// In the sample code, sourceFile indicates the file (directory) in the Download directory to copy, destFile indicates the destination directory in the Download directory, and uri is to URI in fileInfo.
// You can use the URI obtained.
let sourceFile = "datashare:///media/file/102";
let destFile = "datashare:///media/file/101";
let sourceFile = "file://media/file/102";
let destFile = "file://media/file/101";
try {
// Obtain fileAccessHelper by referring to the sample code of fileAccess.createFileAccessHelper.
let copyResult = await fileAccessHelper.copy(sourceFile, destFile);
......@@ -1608,8 +1608,8 @@ Example 2: Copy a file or directory when **force** set to **true**.
// The media library URI is used as an example.
// In the sample code, sourceFile indicates the file (directory) in the Download directory to copy, destFile indicates the destination directory in the Download directory, and uri is to URI in fileInfo.
// You can use the URI obtained.
let sourceFile = "datashare:///media/file/102";
let destFile = "datashare:///media/file/101";
let sourceFile = "file://media/file/102";
let destFile = "file://media/file/101";
try {
// Obtain fileAccessHelper by referring to the sample code of fileAccess.createFileAccessHelper.
let copyResult = await fileAccessHelper.copy(sourceFile, destFile, true);
......@@ -1642,8 +1642,8 @@ Copies a file or directory. This API uses an asynchronous callback to return the
| Name | Type | Mandatory| Description |
| --------- | ------------------------------------------------ | ---- | ------------------------------------------------------------ |
| sourceUri | string | Yes | URI of the file or directory to copy, for example, **datashare:///media/file/102**. |
| destUri | string | Yes | URI of the destination directory, for example, **datashare:///media/file/101**. |
| sourceUri | string | Yes | URI of the file or directory to copy, for example, **file://media/file/102**. |
| destUri | string | Yes | URI of the destination directory, for example, **file://media/file/101**. |
| callback | AsyncCallback&lt;Array&lt;[CopyResult](#copyresult10)&gt;&gt; | Yes | Callback invoked to return the result. If the file or directory is copied successfully, no information is returned. If the file copy fails, **copyResult** is returned.|
**Example**
......@@ -1652,8 +1652,8 @@ Copies a file or directory. This API uses an asynchronous callback to return the
// The media library URI is used as an example.
// In the sample code, sourceFile indicates the file (directory) in the Download directory to copy, destFile indicates the destination directory in the Download directory, and uri is to URI in fileInfo.
// You can use the URI obtained.
let sourceFile = "datashare:///media/file/102";
let destFile = "datashare:///media/file/101";
let sourceFile = "file://media/file/102";
let destFile = "file://media/file/101";
try {
// Obtain fileAccessHelper by referring to the sample code of fileAccess.createFileAccessHelper.
fileAccessHelper.copy(sourceFile, destFile, async (err, copyResult) => {
......@@ -1691,8 +1691,8 @@ Copies a file or directory. This API uses an asynchronous callback to return the
| Name | Type | Mandatory| Description |
| --------- | ------------------------------------------------ | ---- | ------------------------------------------------------------ |
| sourceUri | string | Yes | URI of the file or directory to copy, for example, **datashare:///media/file/102**. |
| destUri | string | Yes | URI of the destination directory, for example, **datashare:///media/file/101**. |
| sourceUri | string | Yes | URI of the file or directory to copy, for example, **file://media/file/102**. |
| destUri | string | Yes | URI of the destination directory, for example, **file://media/file/101**. |
| force | boolean | Yes | Whether to forcibly overwrite the file with the same name. <br>If **force** is **true**, the file with the same name will be overwritten. If **force** is **false** or not specified, the file with the same name will not be overwritten.|
| callback | AsyncCallback&lt;Array&lt;[CopyResult](#copyresult10)&gt;&gt; | Yes | Callback invoked to return the result. If the file or directory is copied successfully, no information is returned. If the file copy fails, **copyResult** is returned.|
......@@ -1702,8 +1702,8 @@ Copies a file or directory. This API uses an asynchronous callback to return the
// The media library URI is used as an example.
// In the sample code, sourceFile indicates the file (directory) in the Download directory to copy, destFile indicates the destination directory in the Download directory, and uri is to URI in fileInfo.
// You can use the URI obtained.
let sourceFile = "datashare:///media/file/102";
let destFile = "datashare:///media/file/101";
let sourceFile = "file://media/file/102";
let destFile = "file://media/file/101";
try {
// Obtain fileAccessHelper by referring to the sample code of fileAccess.createFileAccessHelper.
fileAccessHelper.copy(sourceFile, destFile, true, async (err, copyResult) => {
......
......@@ -51,7 +51,7 @@ For details about the error codes, see [File Management Error Codes](../errorcod
import wantConstant from '@ohos.app.ability.wantConstant';
let uri = 'datashare:///media/image/8';
let uri = 'file://media/image/8';
let bundleName = 'com.demo.test';
try {
fileShare.grantUriPermission(uri, bundleName, wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION | wantConstant.Flags.FLAG_AUTH_WRITE_URI_PERMISSION, (err) => {
......@@ -111,7 +111,7 @@ For details about the error codes, see [File Management Error Codes](../errorcod
```js
import wantConstant from '@ohos.app.ability.wantConstant';
let uri = 'datashare:///media/image/8';
let uri = 'file://media/image/8';
let bundleName = 'com.demo.test';
try {
fileShare.grantUriPermission(uri, bundleName, wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION |
......
......@@ -713,8 +713,8 @@ Starts image preview, with the first image to preview specified. This API can be
```js
let images = [
'datashare:///media/xxxx/2',
'datashare:///media/xxxx/3'
'file://media/xxxx/2',
'file://media/xxxx/3'
];
/* Preview online images.
let images = [
......@@ -756,8 +756,8 @@ Starts image preview. This API can be used to preview local images whose URIs st
```js
let images = [
'datashare:///media/xxxx/2',
'datashare:///media/xxxx/3'
'file://media/xxxx/2',
'file://media/xxxx/3'
];
/* Preview online images.
let images = [
......@@ -804,8 +804,8 @@ Starts image preview, with the first image to preview specified. This API can be
```js
let images = [
'datashare:///media/xxxx/2',
'datashare:///media/xxxx/3'
'file://media/xxxx/2',
'file://media/xxxx/3'
];
/* Preview online images.
let images = [
......@@ -1046,7 +1046,7 @@ Provides APIs for encapsulating file asset attributes.
| Name | Type | Readable| Writable| Description |
| ------------------------- | ------------------------ | ---- | ---- | ------------------------------------------------------ |
| id | number | Yes | No | File asset ID. |
| uri | string | Yes | No | File asset URI, for example, **datashare:///media/image/2**. |
| uri | string | Yes | No | File asset URI, for example, **file://media/image/2**. |
| mimeType | string | Yes | No | Extended file attributes. |
| mediaType<sup>8+</sup> | [MediaType](#mediatype8) | Yes | No | Media type. |
| displayName | string | Yes | Yes | Display file name, including the file name extension. |
......
......@@ -128,7 +128,7 @@ OpenHarmony预置了FileManager文件管理器。系统应用开发者也可以
// 创建文件
// 示例代码sourceUri是Download目录的fileinfo中的URI
// 开发者应根据自己实际获取fileinfo的URI进行开发
let sourceUri = "datashare:///media/file/6";
let sourceUri = "file://media/file/6";
let displayName = "file1";
let fileUri = null;
try {
......
......@@ -654,7 +654,7 @@ createFile(uri: string, displayName: string) : Promise&lt;string&gt;
// 以媒体库uri为例
// 示例代码sourceUri表示Download目录,该uri是对应的fileInfo中uri
// 开发者应根据自己实际获取的uri进行开发
let sourceUri = "datashare:///media/file/6";
let sourceUri = "file://media/file/6";
let displayName = "file1"
let fileUri = null;
try {
......@@ -698,7 +698,7 @@ createFile(uri: string, displayName: string, callback: AsyncCallback&lt;string&g
// 以媒体库uri为例
// 示例代码sourceUri表示Download目录,该uri是对应的fileInfo中uri
// 开发者应根据自己实际获取的uri进行开发
let sourceUri = "datashare:///media/file/6";
let sourceUri = "file://media/file/6";
let displayName = "file1"
try {
// fileAccessHelper 参考 fileAccess.createFileAccessHelper 示例代码获取
......@@ -747,7 +747,7 @@ mkDir(parentUri: string, displayName: string) : Promise&lt;string&gt;
// 以媒体库uri为例
// 示例代码sourceUri表示Download目录,该uri是对应的fileInfo中uri
// 开发者应根据自己实际获取的uri进行开发
let sourceUri = "datashare:///media/file/6";
let sourceUri = "file://media/file/6";
let dirName = "dirTest"
let dirUri = null;
try {
......@@ -791,7 +791,7 @@ mkDir(parentUri: string, displayName: string, callback: AsyncCallback&lt;string&
// 以媒体库uri为例
// 示例代码sourceUri表示Download目录,该uri是对应的fileInfo中uri
// 开发者应根据自己实际获取的uri进行开发
let sourceUri = "datashare:///media/file/6";
let sourceUri = "file://media/file/6";
let dirName = "dirTest"
try {
// fileAccessHelper 参考 fileAccess.createFileAccessHelper 示例代码获取
......@@ -840,7 +840,7 @@ openFile(uri: string, flags: OPENFLAGS) : Promise&lt;number&gt;
// 以媒体库uri为例
// 示例代码targetUri表示Download目录下文件,该uri是对应的fileInfo中uri
// 开发者应根据自己实际获取的uri进行开发
let targetUri = "datashare:///media/file/100";
let targetUri = "file://media/file/100";
try {
// fileAccessHelper 参考 fileAccess.createFileAccessHelper 示例代码获取
let fd = await fileAccessHelper.openFile(targetUri, fileAccess.OPENFLAGS.READ);
......@@ -877,7 +877,7 @@ openFile(uri: string, flags: OPENFLAGS, callback: AsyncCallback&lt;number&gt;) :
// 以媒体库uri为例
// 示例代码targetUri表示Download目录下文件,该uri是对应的fileInfo中uri
// 开发者应根据自己实际获取的uri进行开发
let targetUri = "datashare:///media/file/100";
let targetUri = "file://media/file/100";
try {
// fileAccessHelper 参考 fileAccess.createFileAccessHelper 示例代码获取
fileAccessHelper.openFile(targetUri, fileAccess.OPENFLAGS.READ, function (err, fd) {
......@@ -924,7 +924,7 @@ delete(uri: string) : Promise&lt;number&gt;
// 以媒体库uri为例
// 示例代码targetUri表示Download目录下文件,该uri是对应的fileInfo中uri
// 开发者应根据自己实际获取的uri进行开发
let targetUri = "datashare:///media/file/100";
let targetUri = "file://media/file/100";
try {
// fileAccessHelper 参考 fileAccess.createFileAccessHelper 示例代码获取
let code = await fileAccessHelper.delete(targetUri);
......@@ -962,7 +962,7 @@ delete(uri: string, callback: AsyncCallback&lt;number&gt;) : void
// 以媒体库uri为例
// 示例代码targetUri表示Download目录下文件,该uri是对应的fileInfo中uri
// 开发者应根据自己实际获取的uri进行开发
let targetUri = "datashare:///media/file/100";
let targetUri = "file://media/file/100";
try {
// fileAccessHelper 参考 fileAccess.createFileAccessHelper 示例代码获取
fileAccessHelper.delete(targetUri, function (err, code) {
......@@ -1010,8 +1010,8 @@ move(sourceFile: string, destFile: string) : Promise&lt;string&gt;
// 以媒体库uri为例
// 示例代码sourceFile destFile表示Download目录下文件或文件夹,该uri是对应的fileInfo中uri
// 开发者应根据自己实际获取的uri进行开发
let sourceFile = "datashare:///media/file/102";
let destFile = "datashare:///media/file/101";
let sourceFile = "file://media/file/102";
let destFile = "file://media/file/101";
try {
// fileAccessHelper 参考 fileAccess.createFileAccessHelper 示例代码获取
let fileUri = await fileAccessHelper.move(sourceFile, destFile);
......@@ -1049,8 +1049,8 @@ move(sourceFile: string, destFile: string, callback: AsyncCallback&lt;string&gt;
// 以媒体库uri为例
// 示例代码sourceFile destFile表示Download目录下文件或文件夹,该uri是对应的fileInfo中uri
// 开发者应根据自己实际获取的uri进行开发
let sourceFile = "datashare:///media/file/102";
let destFile = "datashare:///media/file/101";
let sourceFile = "file://media/file/102";
let destFile = "file://media/file/101";
try {
// fileAccessHelper 参考 fileAccess.createFileAccessHelper 示例代码获取
fileAccessHelper.move(sourceFile, destFile, function (err, fileUri) {
......@@ -1098,7 +1098,7 @@ rename(uri: string, displayName: string) : Promise&lt;string&gt;
// 以媒体库uri为例
// 示例代码sourceDir表示Download目录下文件,该uri是对应的fileInfo中uri
// 开发者应根据自己实际获取的uri进行开发
let sourceDir = "datashare:///media/file/100";
let sourceDir = "file://media/file/100";
try {
// fileAccessHelper 参考 fileAccess.createFileAccessHelper 示例代码获取
let DestDir = await fileAccessHelper.rename(sourceDir, "testDir");
......@@ -1136,7 +1136,7 @@ rename(uri: string, displayName: string, callback: AsyncCallback&lt;string&gt;)
// 以媒体库uri为例
// 示例代码sourceDir表示Download目录下文件,该uri是对应的fileInfo中uri
// 开发者应根据自己实际获取的uri进行开发
let sourceDir = "datashare:///media/file/100";
let sourceDir = "file://media/file/100";
try {
// fileAccessHelper 参考 fileAccess.createFileAccessHelper 示例代码获取
fileAccessHelper.rename(sourceDir, "testDir", function (err, DestDir) {
......@@ -1183,7 +1183,7 @@ access(sourceFileUri: string) : Promise&lt;boolean&gt;
// 以媒体库uri为例
// 示例代码sourceDir表示Download目录下文件,该uri是对应的fileInfo中uri
// 开发者应根据自己实际获取的uri进行开发
let sourceDir = "datashare:///media/file/100";
let sourceDir = "file://media/file/100";
try {
// fileAccessHelper 参考 fileAccess.createFileAccessHelper 示例代码获取
let existJudgment = await fileAccessHelper.access(sourceDir);
......@@ -1223,7 +1223,7 @@ access(sourceFileUri: string, callback: AsyncCallback&lt;boolean&gt;) : void
// 以媒体库uri为例
// 示例代码sourceDir表示Download目录下文件,该uri是对应的fileInfo中uri
// 开发者应根据自己实际获取的uri进行开发
let sourceDir = "datashare:///media/file/100";
let sourceDir = "file://media/file/100";
try {
// fileAccessHelper 参考 fileAccess.createFileAccessHelper 示例代码获取
fileAccessHelper.access(sourceDir, function (err, existJudgment) {
......@@ -1269,7 +1269,7 @@ getFileInfoFromUri(uri: string) : Promise\<FileInfo>
// 以媒体库uri为例
// 示例代码sourceUri表示Download目录,该uri是对应的fileInfo中uri
// 开发者应根据自己实际获取的uri进行开发
let sourceUri = "datashare:///media/file/6";
let sourceUri = "file://media/file/6";
try {
// fileAccessHelper 参考 fileAccess.createFileAccessHelper 示例代码获取
let fileInfo = await fileAccessHelper.getFileInfoFromUri(sourceUri);
......@@ -1301,7 +1301,7 @@ getFileInfoFromUri(uri: string, callback: AsyncCallback\<FileInfo>) : void
// 以媒体库uri为例
// 示例代码sourceUri表示Download目录,该uri是对应的fileInfo中uri
// 开发者应根据自己实际获取的uri进行开发
let sourceUri = "datashare:///media/file/6";
let sourceUri = "file://media/file/6";
try {
// fileAccessHelper 参考 fileAccess.createFileAccessHelper 示例代码获取
fileAccessHelper.getFileInfoFromUri(sourceUri, function (err, fileInfo) {
......@@ -1421,7 +1421,7 @@ getThumbnail(uri: string, size: image.Size) : Promise&lt;image.PixelMap&gt;
// 以媒体库uri为例
// 示例代码targetUri表示Download目录下某个媒体文件(图片、音频、视频),该uri是对应的fileInfo中uri
// 开发者应根据自己实际获取的uri进行开发
let targetUri = "datashare:///media/image/100";
let targetUri = "file://media/image/100";
let size = { width: 128, height: 128 };
try {
// fileAccessHelper 参考 fileAccess.createFileAccessHelper 示例代码获取
......@@ -1458,7 +1458,7 @@ try {
// 以媒体库uri为例
// 示例代码targetUri表示Download目录下某个媒体文件(图片、音频、视频),该uri是对应的fileInfo中uri
// 开发者应根据自己实际获取的uri进行开发
let targetUri = "datashare:///media/image/100";
let targetUri = "file://media/image/100";
let size = { width: 128, height: 128 };
try {
// fileAccessHelper 参考 fileAccess.createFileAccessHelper 示例代码获取
......@@ -1566,8 +1566,8 @@ copy(sourceUri: string, destUri: string, force?: boolean) : Promise&lt;Array&lt;
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------- | ---- | ------------------------------------------------------------ |
| sourceUri | string | 是 | 待拷贝的源文件(夹)的 uri,例如:datashare:///media/file/102 |
| destUri | string | 是 | 目标文件夹的 uri,例如:datashare:///media/file/101 |
| sourceUri | string | 是 | 待拷贝的源文件(夹)的 uri,例如:file://media/file/102 |
| destUri | string | 是 | 目标文件夹的 uri,例如:file://media/file/101 |
| force | boolean | 否 | 含有同名文件时是否强制覆盖文件,force 为 true 时强制覆盖文件,force 为空或 false 时不强制覆盖文件 |
**返回值:**
......@@ -1582,8 +1582,8 @@ copy(sourceUri: string, destUri: string, force?: boolean) : Promise&lt;Array&lt;
// 以媒体库uri为例
// 示例代码中的sourceFile表示Download目录下的源文件(夹),destFile表示Download目录下的目标文件夹,该uri对应fileInfo中的uri
// 开发者应根据自己实际获取的uri进行开发
let sourceFile = "datashare:///media/file/102";
let destFile = "datashare:///media/file/101";
let sourceFile = "file://media/file/102";
let destFile = "file://media/file/101";
try {
// fileAccessHelper 参考 fileAccess.createFileAccessHelper 示例代码获取
let copyResult = await fileAccessHelper.copy(sourceFile, destFile);
......@@ -1608,8 +1608,8 @@ try {
// 以媒体库uri为例
// 示例代码中的sourceFile表示Download目录下的源文件(夹),destFile表示Download目录下的目标文件夹,该uri对应fileInfo中的uri
// 开发者应根据自己实际获取的uri进行开发
let sourceFile = "datashare:///media/file/102";
let destFile = "datashare:///media/file/101";
let sourceFile = "file://media/file/102";
let destFile = "file://media/file/101";
try {
// fileAccessHelper 参考 fileAccess.createFileAccessHelper 示例代码获取
let copyResult = await fileAccessHelper.copy(sourceFile, destFile, true);
......@@ -1642,8 +1642,8 @@ copy(sourceUri: string, destUri: string, callback: AsyncCallback&lt;Array&lt;Cop
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------------------------------------------------ | ---- | ------------------------------------------------------------ |
| sourceUri | string | 是 | 待拷贝的源文件(夹)的 uri,例如:datashare:///media/file/102 |
| destUri | string | 是 | 目标文件夹的 uri,例如:datashare:///media/file/101 |
| sourceUri | string | 是 | 待拷贝的源文件(夹)的 uri,例如:file://media/file/102 |
| destUri | string | 是 | 目标文件夹的 uri,例如:file://media/file/101 |
| callback | AsyncCallback&lt;Array&lt;[CopyResult](#copyresult10)&gt;&gt; | 是 | 返回 copyresult 数组,copyResult 为复制操作失败的返回信息,复制成功无返回信息 |
**示例:**
......@@ -1652,8 +1652,8 @@ copy(sourceUri: string, destUri: string, callback: AsyncCallback&lt;Array&lt;Cop
// 以媒体库uri为例
// 示例代码中的sourceFile表示Download目录下的源文件(夹),destFile表示Download目录下的目标文件夹,该uri对应fileInfo中的uri
// 开发者应根据自己实际获取的uri进行开发
let sourceFile = "datashare:///media/file/102";
let destFile = "datashare:///media/file/101";
let sourceFile = "file://media/file/102";
let destFile = "file://media/file/101";
try {
// fileAccessHelper 参考 fileAccess.createFileAccessHelper 示例代码获取
fileAccessHelper.copy(sourceFile, destFile, async (err, copyResult) => {
......@@ -1691,8 +1691,8 @@ copy(sourceUri: string, destUri: string, force: boolean, callback: AsyncCallback
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------------------------------------------------ | ---- | ------------------------------------------------------------ |
| sourceUri | string | 是 | 待拷贝的源文件(夹)的 uri,例如:datashare:///media/file/102 |
| destUri | string | 是 | 目标文件夹的 uri,例如:datashare:///media/file/101 |
| sourceUri | string | 是 | 待拷贝的源文件(夹)的 uri,例如:file://media/file/102 |
| destUri | string | 是 | 目标文件夹的 uri,例如:file://media/file/101 |
| force | boolean | 是 | 含有同名文件时是否强制覆盖文件,force 为 true 时强制覆盖文件,force 为空或 false 时不强制覆盖文件 |
| callback | AsyncCallback&lt;Array&lt;[CopyResult](#copyresult10)&gt;&gt; | 是 | 返回 copyresult 数组,copyResult 为复制操作失败的返回信息,复制成功无返回信息 |
......@@ -1702,8 +1702,8 @@ copy(sourceUri: string, destUri: string, force: boolean, callback: AsyncCallback
// 以媒体库uri为例
// 示例代码中的sourceFile表示Download目录下的源文件(夹),destFile表示Download目录下的目标文件夹,该uri对应fileInfo中的uri
// 开发者应根据自己实际获取的uri进行开发
let sourceFile = "datashare:///media/file/102";
let destFile = "datashare:///media/file/101";
let sourceFile = "file://media/file/102";
let destFile = "file://media/file/101";
try {
// fileAccessHelper 参考 fileAccess.createFileAccessHelper 示例代码获取
fileAccessHelper.copy(sourceFile, destFile, true, async (err, copyResult) => {
......
......@@ -50,7 +50,7 @@ grantUriPermission(uri: string, bundleName: string, mode: number, callback: Asyn
import wantConstant from '@ohos.app.ability.wantConstant';
let uri = 'datashare:///media/image/8';
let uri = 'file://media/image/8';
let bundleName = 'com.demo.test';
try {
fileShare.grantUriPermission(uri, bundleName, wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION | wantConstant.Flags.FLAG_AUTH_WRITE_URI_PERMISSION, (err) => {
......@@ -107,7 +107,7 @@ grantUriPermission(uri: string, bundleName: string, mode: number): Promise&lt;vo
```js
import wantConstant from '@ohos.app.ability.wantConstant';
let uri = 'datashare:///media/image/8';
let uri = 'file://media/image/8';
let bundleName = 'com.demo.test';
try {
fileShare.grantUriPermission(uri, bundleName, wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION |
......
......@@ -708,8 +708,8 @@ startImagePreview(images: Array&lt;string&gt;, index: number, callback: AsyncCal
```js
let images = [
'datashare:///media/xxxx/2',
'datashare:///media/xxxx/3'
'file://media/xxxx/2',
'file://media/xxxx/3'
];
/* 网络图片使用方式
let images = [
......@@ -751,8 +751,8 @@ startImagePreview(images: Array&lt;string&gt;, callback: AsyncCallback&lt;void&g
```js
let images = [
'datashare:///media/xxxx/2',
'datashare:///media/xxxx/3'
'file://media/xxxx/2',
'file://media/xxxx/3'
];
/* 网络图片使用方式
let images = [
......@@ -799,8 +799,8 @@ startImagePreview(images: Array&lt;string&gt;, index?: number): Promise&lt;void&
```js
let images = [
'datashare:///media/xxxx/2',
'datashare:///media/xxxx/3'
'file://media/xxxx/2',
'file://media/xxxx/3'
];
/* 网络图片使用方式
let images = [
......@@ -1041,7 +1041,7 @@ async function example() {
| 名称 | 类型 | 可读 | 可写 | 说明 |
| ------------------------- | ------------------------ | ---- | ---- | ------------------------------------------------------ |
| id | number | 是 | 否 | 文件资源编号 |
| uri | string | 是 | 否 | 文件资源uri(如:datashare:///media/image/2) |
| uri | string | 是 | 否 | 文件资源uri(如:file://media/image/2) |
| mimeType | string | 是 | 否 | 文件扩展属性 |
| mediaType<sup>8+</sup> | [MediaType](#mediatype8) | 是 | 否 | 媒体类型 |
| displayName | string | 是 | 是 | 显示文件名,包含后缀名 |
......
......@@ -120,7 +120,7 @@ Image支持加载存档图、多媒体像素图两种类型。
2. 从媒体库获取的url格式通常如下。
```ts
Image('datashare:///media/5')
Image('file://media/5')
.width(200)
```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册