I'm currently having some problems using the DownloadContent method from the ContentService. Could anyone give me a small example of the best way to use the received stream in order to create a file?
Hi, Andre.
What sort of problems are you having? Are you getting the stream from DownloadContent and just having trouble writing it to a file? Can you post an excerpt of your code?
Thanks,
Scott
Also, are you using C#?
// Fetch the version contents as a stream
String contextID = fDocManService.GetVersionContentsContext( fDocsAuthentication, currNode.ID, 0 );Stream stream = fContentService.DownloadContent( fContentAuthentication, contextID );// Write the stream to the file on disk.FileStream fileStream = File.OpenWrite( saveFileDialog.FileName );byte[] buf = new byte[1024];int numBytes = 0;while ( ( numBytes = stream.Read( buf, 0, buf.Length ) ) > 0 ){ fileStream.Write( buf, 0, numBytes );}fileStream.Close();stream.Close();
Hope this helps,
I tried the code mentioned above but it fails on the DownloadContent. It's saying that I have to increase the MaxReceivedMessageSize ? Question is where to set it to considering I can't tell upfront how big the biggest file will be !?
I would expect that using this implementation for large documents would be a little smarter by for instance downloading the document in chunks.
Any suggestions ?!
Also be aware of the encoding. You have to set it on both side: client and server side to match:
Also are you windows authenticated?