c# - send GZIP stream over WCF -


Below is my code.

I have set the content-encoding header and then use gzip encoding by typing the file stream into the memory stream. Then finally return the memory stream.

However, Android, iOS, and Web browser receive corrupt copies of all streams. None of them are able to read completely through the disintegrated stream on the other side. What important part am I missing?

  Public Stream GetFileStream (string path, string basepath) {FileInfo fi = new FileInfo (basepath + path); //WebOperationContext.Current.OutgoingResponse.ContentType = "App / X-gzip"; WebOperationContext.Current.OutgoingResponse.Headers.Add ("content-encoding", "gzip"); Memorystream ms = new memorystream (); Gzipstream compressstream = new gzipstream (ms, compression mod. Compress); // Receive stream of source file FileStream inFile = fi.OpenRead (); // Hide and compress compressed files already compressed If ((File.GetAttributes (fi.FullName) and FileAttributes.Hidden)! = Properties of file. Hidden & amp; fi.Extension! = ".gz") {/ Copy / source file in the transmission stream. inFile.CopyTo (CompressStream); Log D. (String.Format ("{2} by {2} by {0} to compressed {0}.", Fi, name, fi tall. Toastring (), ms.Length.ToString ())); } Ms.osition = 0; InFile.Close (); MS return; }    

I firmly recommend sending a byte array. Then create a zip stream with the received byte array on the client side.

Comments

Popular posts from this blog

c++ - ERROR: cannot open source file x11\xlib.h -

c - What are pthread cancelation points used for? -

c# - Show a huge number of data in DevExpress GridView -