We have a webservice (so called “service with attachment”) where users can send files with their requests. Users can upload up to 256 MB of files. We have a working solution that parses the request and saves the files, but it’s slow. Sometimes when sending big attachments – server returns timeouts.
We read the request by bytes and looking for a boundary tags (--b5a8d09eeeb161be29def84633d6f6fc). If tag is found then parse the header and read the attachments file base64 encoded data. Also there’s a check for a newline characters.
In my opinion there’s a lot of cycles in this code and it can be done better and improve the performance.
Is there some great examples how is this done and maybe parsing a string (not a byte array) is faster solution? Or maybe there’s other approaches? What do you suggest to do to improve the performance?
Regards,
evilone
Ok, found the answer myself. Using
StreamreaderandReadLine()function is about 40% faster than iterating over single bytes inbyte[]array. If compression is added to requests too like Pareen suggested then it can be more faster.