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 <fm...@apache.org> on 2013/01/15 12:25:41 UTC
Re: DotCMIS issue in DotCMIS.Binding.AtomPub.AtomEntryWriter.WriteContent()
Hi Denis,
Please open a bug report here:
https://issues.apache.org/jira/browse/CMIS
I'll take a look at it.
Thanks,
Florian
> Hi Everyone
>
> There is an issue in the method
> DotCMIS.Binding.AtomPub.AtomEntryWriter.WriteContent()
>
>
>
> private void WriteContent(XmlWriter writer)
>
> {
>
> using (var br = new BinaryReader(stream))
>
> {
>
> var buffer = new byte[BufferSize];
>
> int readBytes = 0;
>
> do
>
> {
>
> readBytes = br.Read(buffer, 0, BufferSize);
>
> writer.WriteBase64(buffer, 0, readBytes);
>
> } while (BufferSize <= readBytes);
>
> }
>
> }
>
>
>
> 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 code above the first read operation returns 4K from the stream
> and
> the condition "while (BufferSize <= readBytes)" finishes the read
> cycle.
>
>
>
> I've fixed the problem with the code below. The read cycle should
> continue
> working unit Read returns the value != 0:
>
>
>
> private void WriteContent(XmlWriter writer)
>
> {
>
> 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);
>
> }
>
>
>
> /*
>
> do
>
> {
>
> readBytes = br.Read(buffer, 0, BufferSize);
>
> writer.WriteBase64(buffer, 0, readBytes);
>
> } while (BufferSize <= readBytes);
>
> */
>
> }
>
> }
>
>
>
> Would you please consider this code and update DotCMIS library.
>
>
>
> Best regards,
>
> Denis Andreev
RE: DotCMIS issue in DotCMIS.Binding.AtomPub.AtomEntryWriter.WriteContent()
Posted by Denis Andreev <an...@elilink.com>.
Hi Florian
I've created the following bug
https://issues.apache.org/jira/browse/CMIS-619
Best regards,
Denis Andreev
-----Original Message-----
From: Florian Müller [mailto:fmui@apache.org]
Sent: Tuesday, January 15, 2013 2:26 PM
To: dev@chemistry.apache.org
Cc: andreev@elilink.com
Subject: Re: DotCMIS issue in DotCMIS.Binding.AtomPub.AtomEntryWriter.WriteContent()
Hi Denis,
Please open a bug report here:
https://issues.apache.org/jira/browse/CMIS
I'll take a look at it.
Thanks,
Florian
> Hi Everyone
>
> There is an issue in the method
> DotCMIS.Binding.AtomPub.AtomEntryWriter.WriteContent()
>
>
>
> private void WriteContent(XmlWriter writer)
>
> {
>
> using (var br = new BinaryReader(stream))
>
> {
>
> var buffer = new byte[BufferSize];
>
> int readBytes = 0;
>
> do
>
> {
>
> readBytes = br.Read(buffer, 0, BufferSize);
>
> writer.WriteBase64(buffer, 0, readBytes);
>
> } while (BufferSize <= readBytes);
>
> }
>
> }
>
>
>
> 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 code above the first read operation returns 4K from the stream
> and the condition "while (BufferSize <= readBytes)" finishes the read
> cycle.
>
>
>
> I've fixed the problem with the code below. The read cycle should
> continue
> working unit Read returns the value != 0:
>
>
>
> private void WriteContent(XmlWriter writer)
>
> {
>
> 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);
>
> }
>
>
>
> /*
>
> do
>
> {
>
> readBytes = br.Read(buffer, 0, BufferSize);
>
> writer.WriteBase64(buffer, 0, readBytes);
>
> } while (BufferSize <= readBytes);
>
> */
>
> }
>
> }
>
>
>
> Would you please consider this code and update DotCMIS library.
>
>
>
> Best regards,
>
> Denis Andreev