doufuhao8085 2018-03-21 13:54
浏览 171
已采纳

是临时文件吗? 如果有多久?

I´m building a web app that allows users to upload files < 5MB, and for this I´m using Request.ParseMultipartForm(5000000), but I´m wondering what happens if a funny guy tries to upload a file bigger than 5MB, documentation is not clear enough https://golang.org/pkg/net/http/#Request.ParseMultipartForm

The whole request body is parsed and up to a total of maxMemory bytes of its file parts are stored in memory, with the remainder stored on disk in temporary files

So, how long "temporary files" really means? because it´s a little ambiguous, does that mean that remaining file will be erase after the handler function returns? or does mean that has a lifetime determined? I wouldn´t want my app to crash if some guys try to do this and I run out of disk space.

  • 写回答

1条回答 默认 最新

  • duanan2732 2018-03-21 14:03
    关注

    Temporary files live for the duration of the request. Parsing of the form and the creation of the temp files are handled by the mime/multipart package.

    When the server finishes the request, it calls Form.RemoveAll to delete any temporary files associated with the form data.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效