Setting file size restrictions when uploading files with Jersey

后端 未结 5 1860
孤独总比滥情好
孤独总比滥情好 2021-01-04 08:42

I\'m currently implementing functionality for uploading files using jersey rest. I would like to set a maximum allowed file size which to me seems like a pretty common requi

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-04 08:59

    If you're using tomcat you can set the the size threshold at which the file will be written to the disk to a sensible value for your machine.

    e.g. if the servlet is in web.xml

    
      Upload Servlet
      YourServletName
    
      
       
       10485760
       
       10240
       
       524288
     
    
    
    

    or using annotations:

    @MultipartConfig(
        maxFileSize=10485760,     // 10Mb max
        fileSizeThreshold=524288, //512 Kb before buffering to disk
        maxRequestSize=10240      // 10Kb of meta data
        location=/tmp             // with permission to write, default uses tomcat tmp
    )
    

    With reference to HttpRequest maximum allowable size in tomcat?

提交回复
热议问题