Click here to Skip to main content
15,888,293 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
I need to upload upto 2 gb of file data in a single go and save it to the database making a WCF call. I have seen a lot of implementations on File Streaming, the problem is I have other related data which I need to send over with the data (couple of user selected items from drop boxes , list of strings etc) along with the streamed data. But streaming only supports single Parameter of System.IO or at max pass some message headers but I have a data table that I need to pass over to the WCF along with the file data, Cant seem to figure out how to send both the data in a single call. Since implementing something like

void UploadFile(System.IO.Stream someStream) doesn't allow any additional parameters to be passed apart from the stream and at the server I can read the stream to byte[] but to insert the byte[] into database I need additional inputs for the file from the user which has many additional metadata values from list<string> elements to long ids.

Need a work around so that I can pass both the stream and preferably a dataset in which I can save all the list<string> , long values

Message contracts don't allow Data contracts which beats the whole purpose of enabling streaming, any ideas anyone ?
Posted
Updated 7-Jun-11 3:29am
v4

1 solution

Serialize your dataset into JSON, take the JSOn string to a byte array, and append that byte string to the front of your file byte array using additional delimiters so you can strip it out on the WCF side.

Result? Single IOStream passed with additional info inside the file itself.

WCF doesn't care about the contents of the stream, and you can do a Stream >> byte[] conversion back on the WCF server-side prior to converting the Stream back to a File.


Remember folks, 1s and 0s. That's all we deal with. 1s and 0s.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900