天天看點

SpringBoot - Processing of multipart/form-data request failed. Unexpected EOF read on the socket

問題原因

上傳檔案還沒到末尾就被用戶端中斷,是超出tomcat檔案連接配接時間了,就被跳轉。

解決方案

在 application.yml 配置檔案裡加上一個tomcat連接配接時長

server:
  connection-timeout: 18000000      

這個是網上很多人都看到的解決方案,但是有一種情況,問題并不是出在後端,而是 CURL 代碼上,請看下面分析……

SpringBoot - Processing of multipart/form-data request failed. Unexpected EOF read on the socket
curl --location --request POST 'localhost:8080/disk/save' \
--form 'file=@"/C:/Users/Boomni_Sun/Desktop/Info.txt"'      

 一開始以為是 header 沒加,後來發現哪怕加了還是報同樣的錯,後來仔細一看,為啥 C 盤前有一個“/”,發現原來 POSTMAN 把他當成在 Linux 裡面,但是我們此時在 Windows 裡測試。

繼續閱讀