Get file size from multipart form upload Content-Length header

拈花ヽ惹草 提交于 2019-11-29 03:44:43

I think that each section of the multipart/form-data request counts toward the overall size of the main Content-Length header.

Found this as a reference: http://chxo.com/be2/20050724_93bf.html

So, perhaps after your headers, you might have:

----WebKitFormBoundaryeoFyqD4zr6smwYDG

Content-Disposition: form-data; name="file"; filename="testfile-downloaded.zip"; size=<file size could be here>
Content-Length: <file size could also be here>
<some other content headers>

<file data>

----WebKitFormBoundaryeoFyqD4zr6smwYDG

All of which would count toward the Content-Length size.

EDIT

Just realized I didn't answer your question. Not sure how to pull out the file size from the file section of the request. Sorry!

Rokman

The data you received is always bigger than you file. Just scan the "boundary" value for the starting and ending of the file.

The reference: How does HTTP file upload work?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!