【发布时间】:2018-10-27 22:22:39
【问题描述】:
我的控制器如下所示:
@RestController
@RequestMapping(path = RestPath.CHALLENGE)
public class ChallengeController {
private final ChallengeService<Challenge> service;
@Autowired
public ChallengeController(ChallengeService service) {
this.service = service;
}
@ApiOperation(value = "Creates a new challenge in the system")
@RequestMapping(method = RequestMethod.POST, consumes = {MediaType.MULTIPART_FORM_DATA_VALUE, MediaType.APPLICATION_OCTET_STREAM_VALUE},
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.CREATED)
public ChallengeDto create(@ApiParam(value = "The details of the challenge to create") @RequestPart("challengeCreate") @Valid @NotNull @NotBlank ChallengeCreateDto challengeCreate,
@ApiParam(value = "The challenge file") @RequestPart("file") @Valid @NotNull @NotBlank MultipartFile file) {
return service.create(challengeCreate, file);
}
}
我已经尝试将“消耗”更改为将 APPLICATION_OCTET_STREAM_VALUE 删除为 MULTIPART_FORM_DATA_VALUE 并尝试将其删除,但这些都没有帮助。
如果您需要更多信息,请告诉我。 谢谢。
【问题讨论】:
-
你可以尝试使用
curl,有时邮递员会有奇怪的行为 -
@GustavoTopete 如何使用 curl 发送文件?
-
见here