未验证 提交 9ab7e849 编写于 作者: O openharmony_ci 提交者: Gitee

!14942 【Monthly】翻译完成 14076:删除API9-beta接口

Merge pull request !14942 from ester.zhou/CM-0221
...@@ -285,95 +285,6 @@ Uploads files. This API uses an asynchronous callback to return the result. ...@@ -285,95 +285,6 @@ Uploads files. This API uses an asynchronous callback to return the result.
}); });
``` ```
## request.upload<sup>(deprecated)</sup>
upload(context: BaseContext, config: UploadConfig): Promise&lt;UploadTask&gt;
Uploads files. This API uses a promise to return the result.
> **NOTE**
>
> This API is supported since API version 9 and is deprecated since API version 9. You are advised to use [request.uploadFile<sup>9+</sup>](#requestuploadfile9).
**Required permissions**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Upload
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| context | [BaseContext](js-apis-inner-application-baseContext.md) | Yes| Application-based context.|
| config | [UploadConfig](#uploadconfig) | Yes| Upload configurations.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;[UploadTask](#uploadtask)&gt; | Promise used to return the **UploadTask** object.|
**Example**
```js
let uploadTask;
let uploadConfig = {
url: 'https://patch',
header: { key1: "value1", key2: "value2" },
method: "POST",
files: [{ filename: "test", name: "test", uri: "internal://cache/test.jpg", type: "jpg" }],
data: [{ name: "name123", value: "123" }],
};
request.upload(globalThis.abilityContext, uploadConfig).then((data) => {
uploadTask = data;
}).catch((err) => {
console.error('Failed to request the upload. Cause: ' + JSON.stringify(err));
});
```
## request.upload<sup>(deprecated)</sup>
upload(context: BaseContext, config: UploadConfig, callback: AsyncCallback&lt;UploadTask&gt;): void
Uploads files. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [request.uploadFile<sup>9+</sup>](#requestuploadfile9-1).
**Required permissions**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Upload
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| context | [BaseContext](js-apis-inner-application-baseContext.md) | Yes| Application-based context.|
| config | [UploadConfig](#uploadconfig) | Yes| Upload configurations.|
| callback | AsyncCallback&lt;[UploadTask](#uploadtask)&gt; | Yes| Callback used to return the **UploadTask** object.|
**Example**
```js
let uploadTask;
let uploadConfig = {
url: 'https://patch',
header: { key1: "value1", key2: "value2" },
method: "POST",
files: [{ filename: "test", name: "test", uri: "internal://cache/test.jpg", type: "jpg" }],
data: [{ name: "name123", value: "123" }],
};
request.upload(globalThis.abilityContext, uploadConfig, (err, data) => {
if (err) {
console.error('Failed to request the upload. Cause: ' + JSON.stringify(err));
return;
}
uploadTask = data;
});
```
## UploadTask ## UploadTask
Implements file uploads. Before using any APIs of this class, you must obtain an **UploadTask** object. Implements file uploads. Before using any APIs of this class, you must obtain an **UploadTask** object.
...@@ -949,82 +860,6 @@ Downloads files. This API uses an asynchronous callback to return the result. ...@@ -949,82 +860,6 @@ Downloads files. This API uses an asynchronous callback to return the result.
}); });
``` ```
## request.download<sup>(deprecated)</sup>
download(context: BaseContext, config: DownloadConfig): Promise&lt;DownloadTask&gt;
Downloads files. This API uses a promise to return the result.
> **NOTE**
>
> This API is supported since API version 9 and is deprecated since API version 9. You are advised to use [request.downloadFile<sup>9+</sup>](#requestdownloadfile9).
**Required permissions**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Download
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| context | [BaseContext](js-apis-inner-application-baseContext.md) | Yes| Application-based context.|
| config | [DownloadConfig](#downloadconfig) | Yes| Download configurations.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;[DownloadTask](#downloadtask)&gt; | Promise used to return the result.|
**Example**
```js
let downloadTask;
request.download(globalThis.abilityContext, { url: 'https://xxxx/xxxx.hap' }).then((data) => {
downloadTask = data;
}).catch((err) => {
console.error('Failed to request the download. Cause: ' + JSON.stringify(err));
})
```
## request.download<sup>(deprecated)</sup>
download(context: BaseContext, config: DownloadConfig, callback: AsyncCallback&lt;DownloadTask&gt;): void;
Downloads files. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [request.downloadFile<sup>9+</sup>](#requestdownloadfile9-1).
**Required permissions**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Download
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| context | [BaseContext](js-apis-inner-application-baseContext.md) | Yes| Application-based context.|
| config | [DownloadConfig](#downloadconfig) | Yes| Download configurations.|
| callback | AsyncCallback&lt;[DownloadTask](#downloadtask)&gt; | Yes| Callback used to return the result.|
**Example**
```js
let downloadTask;
request.download(globalThis.abilityContext, { url: 'https://xxxx/xxxxx.hap',
filePath: 'xxx/xxxxx.hap'}, (err, data) => {
if (err) {
console.error('Failed to request the download. Cause: ' + JSON.stringify(err));
return;
}
downloadTask = data;
});
```
## DownloadTask ## DownloadTask
Implements file downloads. Before using any APIs of this class, you must obtain a **DownloadTask** object. Implements file downloads. Before using any APIs of this class, you must obtain a **DownloadTask** object.
......
# Upload and Download Subsystem Changelog
## cl.request.2 request API Change
Deleted the beta APIs in API version 9:
1. function download(context: BaseContext, config: DownloadConfig, callback: AsyncCallback\<DownloadTask>): void;
2. function download(context: BaseContext, config: DownloadConfig): Promise\<DownloadTask>;
3. function upload(context: BaseContext, config: UploadConfig, callback: AsyncCallback\<UploadTask>): void;
4. function upload(context: BaseContext, config: UploadConfig): Promise\<UploadTask>;
**Change Impact**
The application developed based on an earlier version in the stage model needs to be adapted to the new APIs. Otherwise, the original service logic will be affected.
**Key API/Component Changes**
| Module | Class | Method/Attribute/Enum/Constant | Change Type|
|--------------|--------------|-------------------------------------------------------------------------------------------------------------------|------|
| ohos.request | request | function download(context: BaseContext, config: DownloadConfig, callback: AsyncCallback\<DownloadTask>): void; | Deleted |
| ohos.request | request | function download(context: BaseContext, config: DownloadConfig): Promise\<DownloadTask>; | Deleted |
| ohos.request | request | function upload(context: BaseContext, config: UploadConfig, callback: AsyncCallback\<UploadTask>): void; | Deleted |
| ohos.request | request | function upload(context: BaseContext, config: UploadConfig): Promise\<UploadTask>; | Deleted |
**Adaptation Guide**
Call the new APIs. The following uses **downloadFile** as an example to show how it is called in the new version:
```ts
try {
request.downloadFile(globalThis.abilityContext, { url: 'https://xxxx/xxxxx.hap',
filePath: 'xxx/xxxxx.hap'}, (err, data) => {
if (err) {
console.error('Failed to request the download. Cause: ' + JSON.stringify(err));
return;
}
});
} catch (err) {
console.log("downloadFile callback fail." + "errCode:" + err.code + ",errMessage:" + err.message);
}
```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册