CommonsMultipartFile或MultipartFile一旦进入cloudfoundry就无法工作

时间:2017-05-10 10:46:56

标签: web-services spring-boot amazon-s3 cloudfoundry predix

我正在尝试使用CommonsMultipartFile或MultipartFile上传文件 一旦进入cloudfoundry,它在当地工作正常,但没有工作。

我正在使用Postman进行测试。

以下是示例代码:

@ResponseBody    
    @RequestMapping(value = "/api/stw/upload1", method = RequestMethod.POST)
    public String upload1(@RequestParam(name="text",required=true) MultipartFile text){

        return "done";

    }

以下是我试图拨打CF网址时Postman的回复。

{
  "timestamp": 1494397075418,
  "status": 400,
  "error": "Bad Request",
  "exception": "org.springframework.web.bind.MissingServletRequestParameterException",
  "message": "Required MultipartFile parameter 'text' is not present",
  "path": "/api/stw/upload1"
}

注意:我在表单数据中传递postman所需的键值。它在本地工作但不在CF上工作。 例如:text(Key) - uploadfile(Value)

    **Request Header**

    Accept:*/*
    Accept-Encoding:gzip, deflate, br
    Accept-Language:en-US,en;q=0.8,kn;q=0.6
    Cache-Control:no-cache
    Connection:keep-alive
    Content-Length:32354
    Content-Type:multipart/form-data; boundary=----WebKitFormBoundary10QktAWiD1GCsBKF
    DNT:1
    Host:<CF Service URL>
    Origin:chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop
    Postman-Token:d22500e6-f0d9-0f29-b981-78a45b6e4524
    Pragma:no-cache
    User-Agent:Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36

**Request Payload**
------WebKitFormBoundary10QktAWiD1GCsBKF
Content-Disposition: form-data; name="uploadFile"; filename="error.txt"
Content-Type: text/plain


------WebKitFormBoundary10QktAWiD1GCsBKF--

1 个答案:

答案 0 :(得分:0)

问题是公共上传pom依赖。

我正在使用commons-upload上传文件,这些文件在本地工作正常,但是在推送到Predix时它给出了多部分错误。因此在删除它和相应的bean配置然后推送到Predix之后它工作正常。