Skip to content

Commit

Permalink
docs: update upload
Browse files Browse the repository at this point in the history
  • Loading branch information
czy88840616 committed Jul 26, 2024
1 parent 9edcf6f commit 1e6169e
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 7 deletions.
39 changes: 39 additions & 0 deletions site/docs/extensions/upload.md
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,45 @@ export default {



### 同名 Field

从 v3.16.6 开始,组件支持同名 Field。

```typescript
// src/config/config.default.ts
import { tmpdir } from 'os';
import { join } from 'path';

export default {
// ...
upload: {
allowFieldsDuplication: true
},
}

```

开启 `allowFieldsDuplication` 之后,同名的 Field 会被合并为数组。

```typescript
import { Controller, Inject, Post, Files, Fields } from '@midwayjs/core';

@Controller('/')
export class HomeController {
@Post('/upload')
async upload(@Files() files, @Fields() fields) {
/*
fields = {
name: ['name1', 'name2'],
otherName: 'nameOther'
// ...
}
*/
}
}
```




Expand Down
2 changes: 1 addition & 1 deletion site/docs/legacy/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ export class MainConfiguration implements ILifeCycle {



Midway 在框架侧提供了一些常用的表达式,放在 `@midwayjs/decorator` 中供大家使用。
Midway 在框架侧提供了一些常用的表达式,放在 `@midwayjs/core` 中供大家使用。

```typescript
import { FORMAT } from '@midwayjs/core';
Expand Down
9 changes: 3 additions & 6 deletions site/docs/router_table.md
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,7 @@ export class DataController {
```typescript
// src/configuration.ts
import { MidwayWebRouterService } from '@midwayjs/core';
import { Configuration, Inject } from '@midwayjs/decorator';
import { Configuration, Inject, MidwayWebRouterService } from '@midwayjs/core';
import { DataController } from './controller/data.controller';
@Configuration({
Expand Down Expand Up @@ -481,8 +480,7 @@ export class MainConfiguration {
```typescript
// src/configuration.ts
import { MidwayWebRouterService } from '@midwayjs/core';
import { Configuration, Inject } from '@midwayjs/decorator';
import { Configuration, Inject, MidwayWebRouterService } from '@midwayjs/core';
@Configuration({
// ...
Expand Down Expand Up @@ -524,8 +522,7 @@ export class MainConfiguration {
```typescript
// src/configuration.ts
import { MidwayServerlessFunctionService } from '@midwayjs/core';
import { Configuration, Inject } from '@midwayjs/decorator';
import { Configuration, Inject, MidwayServerlessFunctionService } from '@midwayjs/core';
@Configuration({
// ...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,47 @@ Therefore, you can add `match` or `ignore` configuration to the configuration to



### Same name Field

The componennt support Field with the same name since v3.16.6.

```typescript
// src/config/config.default.ts
import { tmpdir } from 'os';
import { join } from 'path';

export default {
// ...
upload: {
allowFieldsDuplication: true
},
}

```

After `allowFieldsDuplication` is enabled, Fields with the same name will be merged into an array.

```typescript
import { Controller, Inject, Post, Files, Fields } from '@midwayjs/core';

@Controller('/')
export class HomeController {
@Post('/upload')
async upload(@Files() files, @Fields() fields) {
/*
fields = {
name: ['name1', 'name2'],
otherName: 'nameOther'
// ...
}
*/
}
}
```






Expand Down

0 comments on commit 1e6169e

Please sign in to comment.