How to set the max size of upload file

前端 未结 16 689
没有蜡笔的小新
没有蜡笔的小新 2020-12-04 12:13

I\'m developing application based on Spring Boot and AngularJS using JHipster. My question is how to set max size of uploading files?

If I\'m trying

16条回答
  •  生来不讨喜
    2020-12-04 12:38

    I know this is extremely late to the game, but I wanted to post the additional issue I faced when using mysql, if anyone faces the same issue in future.

    As some of the answers mentioned above, setting these in the application.properties will mostly fix the problem

    spring.http.multipart.max-file-size=16MB
    spring.http.multipart.max-request-size=16MB
    

    I am setting it to 16 MB, because I am using mysql MEDIUMBLOB datatype to store the file.

    But after fixing the application.properties, When uploading a file > 4MB gave the error: org.springframework.dao.TransientDataAccessResourceException: PreparedStatementCallback; SQL [insert into test_doc(doc_id, duration_of_doc, doc_version_id, file_name, doc) values (?, ?, ?, ?, ?)]; Packet for query is too large (6656781 > 4194304). You can change this value on the server by setting the max_allowed_packet' variable.; nested exception is com.mysql.jdbc.PacketTooBigException: Packet for query is too large (6656781 > 4194304). You can change this value on the server by setting the max_allowed_packet' variable.

    So I ran this command from mysql:

    SET GLOBAL max_allowed_packet = 1024*1024*16;
    

提交回复
热议问题