c# - HttpWebRequest is caching even with AllowWriteStreamBuffering false -
i'm trying implement upload progress bar on ios application. current implementation simple trick:
using (stream requeststream = request.getrequeststream ()) { byte[] datatoupload = this.datatoupload; int datatouploadlength = datatoupload.length; int uploadedsofar = 0; while (uploadedsofar < datatouploadlength) { int toupload = 8192; if (uploadedsofar + toupload > datatouploadlength) { toupload = datatouploadlength - uploadedsofar; } requeststream.write (datatoupload, uploadedsofar, toupload); uploadedsofar += toupload; this.setuploadedratio ((float)uploadedsofar / (float)datatouploadlength); }
the problem requeststream.write() instant until around 100kb of data sent, becomes more logical , setuploadedratio() method shown above called should. when file huge, not big deal, though can still see takes percent instantly , start percent slower. on slow connections, sending 60kb file result in showing progress bar goes instantly 100% actual upload not completed @ all, can't display what's going on.
i did complete showcase exposes problem (on monotouch ios), link available below: https://github.com/rflex/monotouch-upload-showcase
this interesting stuff is: https://github.com/rflex/monotouch-upload-showcase/blob/master/testupload/uploader.cs
as long set either httpwebrequest.contentlength or httpwebrequest.sendchunked before calling getrequeststream, data send sent server each call stream.[begin]write. if write file in small chunks suggests, can idea of how far along you.
Comments
Post a Comment