我只是嘗試使用以下文章在 AWS Lambda 上運(yùn)行 Spring Boot 應(yīng)用程序:https : //github.com/awslabs/aws-serverless-java-container/wiki/Quick-start---Spring-Boot基本請求工作正常,但發(fā)送文件似乎會導(dǎo)致問題。在本地運(yùn)行應(yīng)用程序工作正常:@RestController@EnableWebMvcpublic class PingController { @RequestMapping(path = "/ping", method = RequestMethod.GET) public Map<String, String> ping() { Map<String, String> pong = new HashMap<>(); pong.put("pong", "Hello, World!"); return pong; } @RequestMapping(path = "/ping", method = RequestMethod.POST) public Map<String, Long> ping(@RequestParam("file") MultipartFile file) { Map<String, Long> pong = new HashMap<>(); pong.put("filesize", file.getSize()); return pong; }}/ping 上的 GET 會按預(yù)期返回有效消息:{ "pong": "Hello, World!"}向包含圖像的 /ping 發(fā)送 POST 會導(dǎo)致以下異常:{ "timestamp": 1540237302941, "status": 500, "error": "Internal Server Error", "exception": "org.springframework.web.multipart.MultipartException", "message": "Could not parse multipart servlet request; nested exception is java.lang.IllegalArgumentException: File path not allowed: /image.jpeg", "path": "/ping"}將以下行添加到application.properties文件中沒有幫助:spring.http.multipart.location=/tmp/甚至指定的資源是否存在都無關(guān)緊要。POST 到 /ping2(不存在)會導(dǎo)致相同的異常。
1 回答

ibeautiful
TA貢獻(xiàn)1993條經(jīng)驗(yàn) 獲得超6個(gè)贊
這是亞馬遜圖書館中的一個(gè)錯(cuò)誤,幾天前已修復(fù)??稍诖颂帿@得更多信息。只要確保使用 1.2 或更高版本:
<dependency>
<groupId>com.amazonaws.serverless</groupId>
<artifactId>aws-serverless-java-container-spring</artifactId>
<version>1.2</version>
</dependency>
添加回答
舉報(bào)
0/150
提交
取消