From 574254aa39bc493dffc3e83a32a5962b4af5b7bc Mon Sep 17 00:00:00 2001 From: caochuan Date: Wed, 17 May 2023 14:12:07 +0800 Subject: [PATCH] add deletephotorequest docs Signed-off-by: caochuan --- .../reference/apis/js-apis-userFileManager.md | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/zh-cn/application-dev/reference/apis/js-apis-userFileManager.md b/zh-cn/application-dev/reference/apis/js-apis-userFileManager.md index d4630b1829c..0a1211cec48 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-userFileManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-userFileManager.md @@ -898,6 +898,85 @@ async function example() { } ``` +### deletePhotoAssetRequest10+ + +deletePhotoAssetRequest(uriList: Array<string>, callback: AsyncCallback<void>): void; + +请求删除图片资源弹框,使用callback方式返回异步结果。 + +**模型约束**:此接口仅可在Stage模型下使用。 + +**需要权限**:ohos.permission.WRITE_IMAGEVIDEO + +**系统能力**:SystemCapability.FileManagement.UserFileManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | ---------- | +| uriList | Array<string> | 是 | 图片uri | +| callback | AsyncCallback<void> | 是 | 回调返回空 | + +**示例:** + +```ts +async function example() { + console.log("testLog in"); + globalThis.mainAbilityContext = this.context; + let uri = ["file://media/Photo/1"]; + const mgr = userFileManager.getUserFileMgr(globalThis.mainAbilityContext); + mgr.deletePhotoAssetRequest(uri, (err) => { + if (err) { + console.error("deletePhotoAssetRequest failed. error " + err.code + err.message); + } else { + console.log("deletePhotoAssetRequest success"); + } + }); + console.log("testLog end"); +} +``` + +### deletePhotoAssetRequest10+ + +deletePhotoAssetRequest(uriList: Array<string>): Promise<void>; + +请求删除图片资源弹框,使用promise方式返回异步结果。 + +**模型约束**:此接口仅可在Stage模型下使用。 + +**需要权限**:ohos.permission.WRITE_IMAGEVIDEO + +**系统能力**:SystemCapability.FileManagement.UserFileManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------------------- | ---- | ------- | +| uriList | Array<string> | 是 | 图片uri | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------- | +| Promise<void> | Promise返回空 | + +**示例:** + +```ts +async function example() { + try { + console.log("testLog in"); + globalThis.mainAbilityContext = this.context; + let uri = ["file://media/Photo/1"]; + const mgr = userFileManager.getUserFileMgr(globalThis.mainAbilityContext); + await mgr.deletePhotoAssetRequest(uri); + console.log("deletePhotoAssetRequest success"); + } catch (err) { + console.error("deletePhotoAssetRequest failed. error " + err.code + err.message); + } +} +``` + ## FileAsset 提供封装文件属性的方法。 -- Gitee