-
Notifications
You must be signed in to change notification settings - Fork 578
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7ce7537
commit 518b61f
Showing
4 changed files
with
84 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
--- | ||
slug: release/3.18.0 | ||
title: Release 3.18.0 | ||
authors: [harry] | ||
tags: [release] | ||
|
||
|
||
|
||
--- | ||
|
||
升级请参考 [如何更新 Midway](/docs/how_to_update_midway) 中描述,请不要单独升级某个组件包。 | ||
|
||
本次 3.18 版本,主要修复了新的 busboy 组件的一些遗留问题,以及新增了一种上传模式。 | ||
|
||
下面是更为细节的描述。 | ||
|
||
|
||
## 异步迭代器上传模式 | ||
|
||
为了支持单次多个文件的流式上传,新版本使用了异步迭代器模型转换了上传流,这个新的模式用于替代原有的流式模式。 | ||
|
||
```typescript | ||
// src/config/config.default.ts | ||
export default { | ||
// ... | ||
busboy: { | ||
mode: 'asyncIterator', | ||
}, | ||
} | ||
``` | ||
|
||
装饰器的入参也已经变成了异步迭代器。 | ||
|
||
```typescript | ||
import { Controller, Post, Files, Fields } from '@midwayjs/core'; | ||
import { UploadStreamFileInfo, UploadStreamFieldInfo } from '@midwayjs/busboy'; | ||
|
||
@Controller('/') | ||
export class HomeController { | ||
|
||
@Post('/upload', /*...*/) | ||
async upload( | ||
@Files() fileIterator: AsyncGenerator<UploadStreamFileInfo>, | ||
@Fields() fieldIterator: AsyncGenerator<UploadStreamFieldInfo> | ||
) { | ||
// ... | ||
} | ||
} | ||
``` | ||
|
||
我们可以通过循环迭代器获取到每个上传的文件。 | ||
|
||
```typescript | ||
for await (const file of fileIterator) { | ||
const { filename, data } = file; | ||
// ... | ||
} | ||
``` | ||
|
||
进而可以方便的做后续处理。 | ||
|
||
更多的内容,请参考 [细节文档](/docs/extensions/busboy)。 | ||
|
||
|
||
|
||
## 此外还有更多的变化 | ||
|
||
* 流式上传时的 `fieldName` 字段现在恢复了 | ||
* httpClient 现在默认的配置不再会被单次请求覆盖 | ||
* 数据源的优先级 NPE 报错现在已经修复了 | ||
* 业务中的 https 配置现在在 dev 的输出提示中也变得正常了 | ||
|
||
以及一大批依赖进行了更新,可以参考我们的 [ChangeLog](https://midwayjs.org/changelog/v3.18.0)。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters