You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@chemistry.apache.org by "Florian Müller (JIRA)" <ji...@apache.org> on 2013/01/15 13:44:13 UTC

[jira] [Resolved] (CMIS-619) Wrong stream reading in DotCMIS.Binding.AtomPub.AtomEntryWriter.WriteContent()

     [ https://issues.apache.org/jira/browse/CMIS-619?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Florian Müller resolved CMIS-619.
---------------------------------

       Resolution: Fixed
    Fix Version/s: DotCMIS 0.5

Thanks for the report!
                
> Wrong stream reading in DotCMIS.Binding.AtomPub.AtomEntryWriter.WriteContent()
> ------------------------------------------------------------------------------
>
>                 Key: CMIS-619
>                 URL: https://issues.apache.org/jira/browse/CMIS-619
>             Project: Chemistry
>          Issue Type: Bug
>          Components: dotcmis
>            Reporter: Denis Andreev
>            Assignee: Florian Müller
>             Fix For: DotCMIS 0.5
>
>
> The problem is that the method "Stream.Read() or BinaryReader.Read()" may read less amount of bytes than the provided buffer size when the end of the stream has not been reached yet.
> For example.
> The file "File1.txt" of size 30K is requested by HttpWebRequest to download from a server and transfer it to Alfresco.
> HttpWebRequest returns System.Net.ConnectStream.
> The  buffer size to read from stream is 65K.
> In the current code the first read operation returns 4K from the stream and the condition "while (BufferSize <= readBytes)" finishes the read cycle.
> The problem can be fixed by the code below:
> using (var br = new BinaryReader(stream))
> {
>    var buffer = new byte[BufferSize];
>    int readBytes = 0;
>    while ((readBytes = br.Read(buffer, 0, BufferSize)) != 0)
>    {
>       writer.WriteBase64(buffer, 0, readBytes);
>    }
> }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira