0

我可以在邮递员中使用 POST 发布数据“标题”和“序列”。

但是,我应该如何发布图像?多张图片呢?

我试过使用

1)以表单数据为主体,以img为键并在其中放置一个文件,但是img仍然为空。回复:

{
    "title": "test title 2",
    "sequence": 5,
    "_id": "5bd1658f39702a5df8a1e447",
    "createdAt": "2018-10-25T06:41:19.197Z",
    "updatedAt": "2018-10-25T06:41:19.358Z",
    "__v": 0,
    "img": null,
    "id": "5bd1658f39702a5df8a1e447"
}

2)将图像转换为base 64字符串并将其发布为json:

要求:

{
  "title": "test title 3",
  "sequence": 6
  "img": "base64stringxxxxx"
}

回复:

{
    "message": "An internal server error occurred",
    "statusCode": 500,
    "error": "Internal Server Error"
}

在此处输入图像描述

4

0 回答 0