Encoding corruption and file streaming

When I was writing JMVC, I wanted to write file upload for HTTP.

The method used to process file stream in Http had some errors, I looked up GitHub and found someone provided the whole parsing of Http protocol upload stream.

In certain parts, there might be multiple upload sections, but how to identify each block of binary into a file?

Based on UTF8 encoding, we get the bytes of the file section start bytes, then keep reading bytes one by one, then keep moving the section range forward, whenever a match of the identifier bytes is met, start reading file bytes, when a terminator is met, parse the file according to the header information of that bytes block, keeps doing so till all files are processed.

This is how to process streams in general if a file is very big.

留下你的评论