Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF streams in 4K chunks!

Tags:

wcf

streaming

My WCF project uses Mtom and streaming, and set the MaxBytesPerRead to 32K (on client and server) but when I run

read = fs.read(buffer, 0, buffer.length)

it doesn't let me read more than 4096 bytes (4k) at a time (the 32K buffer doesn't fill up- it's padded with zeroes)

Is there any way I can stream my multi-megabyte file in chunks larger than 4K (please say yes) ???

like image 631
romrom Avatar asked Nov 05 '22 01:11

romrom


1 Answers

4096 is the default size for the read buffer on a FileStream, which I assume is what your are returning. I am not really sure how the 4k limit is affecting you, but your alternative is to read the entire file into a MemoryStream and send it that way.

like image 51
scottrudy Avatar answered Nov 15 '22 06:11

scottrudy