Get file size from multipart form upload Content-Length header

后端 未结 2 1545
星月不相逢
星月不相逢 2020-12-16 15:36

So, I\'m uploading a file, and then downloading it... but the Content-Length in the upload headers do not match the file size. I\'m guessing there is some other data involve

2条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-16 16:27

    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=
    Content-Length: 
    
    
    
    
    ----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!

提交回复
热议问题