Skip to content

Commit

Permalink
docs: file must appear after other fiels when using getFileStream (#982)
Browse files Browse the repository at this point in the history
  • Loading branch information
dead-horse authored and fengmk2 committed Jun 2, 2017
1 parent 8fc63fd commit 2f232f3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions docs/source/en/basics/controller.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ Content-Type: application/json; charset=UTF-8
{"title": "controller", "content": "what is controller"}
```

The 1st line of the request contains 3 information, first 2 of which are commonly used:
The 1st line of the request contains 3 information, first 2 of which are commonly used:

- method: it's `POST` in this example.
- path: it's `/api/posts`, the query, if any, is placed here too.
Expand All @@ -171,7 +171,7 @@ From the 2nd line to the place where the 1st empty line appears is the Header pa

The whole following content is the request body, which can be set by POST, PUT, DELETE, etc. methods and the server resolves the request body according to Content-Type.

When the sever finishes to process the request, a HTTP response is send back to the client:
When the sever finishes to process the request, a HTTP response is send back to the client:

```
HTTP/1.1 201 Created
Expand All @@ -195,7 +195,7 @@ It can be seen from the above HTTP request examples that there are many places c

### query

Usually the Query String, string following `?` in the URL, is used to send parameters by request of GET type. For example, `category=egg&language=node` in `GET /posts?category=egg&language=node` is parameter that user sends. We can acquire this parsed parameter body through `context.query`:
Usually the Query String, string following `?` in the URL, is used to send parameters by request of GET type. For example, `category=egg&language=node` in `GET /posts?category=egg&language=node` is parameter that user sends. We can acquire this parsed parameter body through `context.query`:

```js
exports.listPosts = function* (ctx) {
Expand Down Expand Up @@ -336,8 +336,8 @@ module.exports = function* (ctx) {

To acquire user uploaded files conveniently by `context.getFileStream`, 2 conditions must be matched:

- file uploading must appear before other fields.
- only 1 file can be uploaded in the same time.
- only one file can be uploaded in the same time.
- file uploading must appear after other fields, otherwise we may can't access fields when we got file stream.

If more than 1 file are to be uploaded, `ctx.getFileStream()` is no longer the way but the following:

Expand Down
2 changes: 1 addition & 1 deletion docs/source/zh-cn/basics/controller.md
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,8 @@ module.exports = function* (ctx) {

要通过 `context.getFileStream` 便捷的获取到用户上传的文件,需要满足两个条件:

- 上传文件必须在其他 field 之前。
- 只支持上传一个文件。
- 上传文件必须在所有其他的 fields 后面,否则在拿到文件流时可能还获取不到 fields。

如果要获取同时上传的多个文件,不能通过 `ctx.getFileStream()` 来获取,只能通过下面这种方式:

Expand Down

0 comments on commit 2f232f3

Please sign in to comment.