I have a WCF service that returns an array of bytes with a Zip file (50 MB) to any client that requests it. If Zip is very small (say, 1 MB), the SOAP response comes from WCF with a byte array built into it. But the response size is very large even for a 1 MB file. If I try to transfer a 50 MB file, the service freezes and throws an exception from memory because the SOAP response becomes huge in size.
What is the best option with WCF / web service for transferring large files (mostly ZIP format) as I send back an array of bytes. Is there a good approach instead to send the file?
Is WCF / web service the best way to transfer large files to any client, or is there any other better option / technology to provide compatibility and scalability for 10,000 users?
My code is below:
String pathfordownload = @"D:\New Folder.zip"; FileStream F2D = new FileStream(pathfordownload, FileMode.Open,FileAccess.Read); BinaryReader binReader = new BinaryReader(F2D); binReader.BaseStream.Position = 0; byte[] binFile = binReader.ReadBytes(Convert.ToInt32 (binReader.BaseStream.Length)); binReader.Close(); return binFile;
The working part / real information will be really useful, as I struggle with all the data available on Google and did not have good results last week.
You can stream through WCF , and then you can send (almost) unlimited length files.
I faced the same problem. Lack of memory is inevitable because you are using byte arrays.
, - HD.
. , . , http.
, , http- . , HttpRequest WebClient, . SOAP, Delete (string url), REST, .
, . , , 10000 (?), , . , , , , SAN, IT .
Source: https://habr.com/ru/post/1755747/More articles:Play! + Siena + GAE + JUnit - javaParsing Analyzer - c #In JavaScript, how do I access an object inherited from Array using the [] operator? - javascriptA few questions about DLR - c #Does the Process.Start parameter containing spaces have problems with XP? - c #asp.net: link to the page relative to the root in normal html server-side controls - urlConverting types from string to custom type - c #Javascript: exception and error strategy - javascriptHow to make sure that the buffer is cached on shoulder 9 - armReformatting text (or, better, LaTeX) in 80 columns in SciTE - word-wrapAll Articles