How to transfer a large Zip file (50 MB) using the WCF service through SOAP to any client?

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.

+3
source share
2 answers

You can stream through WCF , and then you can send (almost) unlimited length files.

+4
source

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 .

+2

Source: https://habr.com/ru/post/1755747/


All Articles