CMIS-955: increased buffers for better upload performance

git-svn-id: https://svn.apache.org/repos/asf/chemistry/dotcmis/trunk@1714233 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/DotCMIS/binding/atompub/atompub-writer.cs b/DotCMIS/binding/atompub/atompub-writer.cs
index 525e889..3619a1e 100644
--- a/DotCMIS/binding/atompub/atompub-writer.cs
+++ b/DotCMIS/binding/atompub/atompub-writer.cs
@@ -87,69 +87,72 @@
             XmlWriterSettings xmlWriterSettings = new XmlWriterSettings();

             xmlWriterSettings.Encoding = new UTF8Encoding(false);

 

-            using (XmlWriter writer = XmlWriter.Create(outStream, xmlWriterSettings))

+            using (BufferedStream bufferedStream = new BufferedStream(outStream, 64 * 1204))

             {

-                // start doc

-                writer.WriteStartDocument();

-

-                // start entry

-                writer.WriteStartElement(AtomWriter.PrefixAtom, AtomPubConstants.TagEntry, AtomPubConstants.NamespaceAtom);

-                writer.WriteAttributeString("xmlns", AtomWriter.PrefixAtom, null, AtomPubConstants.NamespaceAtom);

-                writer.WriteAttributeString("xmlns", AtomWriter.PrefixCMIS, null, AtomPubConstants.NamespaceCMIS);

-                writer.WriteAttributeString("xmlns", AtomWriter.PrefixRestAtom, null, AtomPubConstants.NamespaceRestAtom);

-                if (filename != null)

+                using (XmlWriter writer = XmlWriter.Create(bufferedStream, xmlWriterSettings))

                 {

-                    writer.WriteAttributeString("xmlns", AtomWriter.PrefixApacheChemistry, null, AtomPubConstants.NamespaceApacheChemistry);

-                }

+                    // start doc

+                    writer.WriteStartDocument();

 

-                // atom:id

-                writer.WriteStartElement(AtomWriter.PrefixAtom, AtomPubConstants.TagAtomId, AtomPubConstants.NamespaceAtom);

-                writer.WriteString("urn:uuid:00000000-0000-0000-0000-00000000000");

-                writer.WriteEndElement();

-

-                // atom:title

-                writer.WriteStartElement(AtomWriter.PrefixAtom, AtomPubConstants.TagAtomTitle, AtomPubConstants.NamespaceAtom);

-                writer.WriteString(GetTitle());

-                writer.WriteEndElement();

-

-                // atom:updated

-                writer.WriteStartElement(AtomWriter.PrefixAtom, AtomPubConstants.TagAtomUpdated, AtomPubConstants.NamespaceAtom);

-                writer.WriteString(GetUpdated());

-                writer.WriteEndElement();

-

-                // content

-                if (stream != null)

-                {

-                    writer.WriteStartElement(AtomWriter.PrefixRestAtom, AtomPubConstants.TagContent, AtomPubConstants.NamespaceRestAtom);

-

-                    writer.WriteStartElement(AtomWriter.PrefixRestAtom, AtomPubConstants.TagContentMediatype, AtomPubConstants.NamespaceRestAtom);

-                    writer.WriteString(mediaType);

-                    writer.WriteEndElement();

-

+                    // start entry

+                    writer.WriteStartElement(AtomWriter.PrefixAtom, AtomPubConstants.TagEntry, AtomPubConstants.NamespaceAtom);

+                    writer.WriteAttributeString("xmlns", AtomWriter.PrefixAtom, null, AtomPubConstants.NamespaceAtom);

+                    writer.WriteAttributeString("xmlns", AtomWriter.PrefixCMIS, null, AtomPubConstants.NamespaceCMIS);

+                    writer.WriteAttributeString("xmlns", AtomWriter.PrefixRestAtom, null, AtomPubConstants.NamespaceRestAtom);

                     if (filename != null)

                     {

-                        writer.WriteStartElement(AtomWriter.PrefixApacheChemistry, AtomPubConstants.TagContentFilename, AtomPubConstants.NamespaceApacheChemistry);

-                        writer.WriteString(filename);

+                        writer.WriteAttributeString("xmlns", AtomWriter.PrefixApacheChemistry, null, AtomPubConstants.NamespaceApacheChemistry);

+                    }

+

+                    // atom:id

+                    writer.WriteStartElement(AtomWriter.PrefixAtom, AtomPubConstants.TagAtomId, AtomPubConstants.NamespaceAtom);

+                    writer.WriteString("urn:uuid:00000000-0000-0000-0000-00000000000");

+                    writer.WriteEndElement();

+

+                    // atom:title

+                    writer.WriteStartElement(AtomWriter.PrefixAtom, AtomPubConstants.TagAtomTitle, AtomPubConstants.NamespaceAtom);

+                    writer.WriteString(GetTitle());

+                    writer.WriteEndElement();

+

+                    // atom:updated

+                    writer.WriteStartElement(AtomWriter.PrefixAtom, AtomPubConstants.TagAtomUpdated, AtomPubConstants.NamespaceAtom);

+                    writer.WriteString(GetUpdated());

+                    writer.WriteEndElement();

+

+                    // content

+                    if (stream != null)

+                    {

+                        writer.WriteStartElement(AtomWriter.PrefixRestAtom, AtomPubConstants.TagContent, AtomPubConstants.NamespaceRestAtom);

+

+                        writer.WriteStartElement(AtomWriter.PrefixRestAtom, AtomPubConstants.TagContentMediatype, AtomPubConstants.NamespaceRestAtom);

+                        writer.WriteString(mediaType);

+                        writer.WriteEndElement();

+

+                        if (filename != null)

+                        {

+                            writer.WriteStartElement(AtomWriter.PrefixApacheChemistry, AtomPubConstants.TagContentFilename, AtomPubConstants.NamespaceApacheChemistry);

+                            writer.WriteString(filename);

+                            writer.WriteEndElement();

+                        }

+

+                        writer.WriteStartElement(AtomWriter.PrefixRestAtom, AtomPubConstants.TagContentBase64, AtomPubConstants.NamespaceRestAtom);

+                        WriteContent(writer);

+                        writer.WriteEndElement();

+

                         writer.WriteEndElement();

                     }

 

-                    writer.WriteStartElement(AtomWriter.PrefixRestAtom, AtomPubConstants.TagContentBase64, AtomPubConstants.NamespaceRestAtom);

-                    WriteContent(writer);

+                    // object

+                    AtomWriter.ObjectSerializer.Serialize(writer, cmisObject);

+

+                    // end entry

                     writer.WriteEndElement();

 

-                    writer.WriteEndElement();

+                    // end document

+                    writer.WriteEndDocument();

+

+                    writer.Flush();

                 }

-

-                // object

-                AtomWriter.ObjectSerializer.Serialize(writer, cmisObject);

-

-                // end entry

-                writer.WriteEndElement();

-

-                // end document

-                writer.WriteEndDocument();

-

-                writer.Flush();

             }

         }

 

diff --git a/DotCMIS/binding/atompub/atompub.cs b/DotCMIS/binding/atompub/atompub.cs
index 872cb54..a3414c4 100644
--- a/DotCMIS/binding/atompub/atompub.cs
+++ b/DotCMIS/binding/atompub/atompub.cs
@@ -2127,7 +2127,7 @@
             HttpUtils.Output output = delegate(Stream stream)

             {

                 int b;

-                byte[] buffer = new byte[4096];

+                byte[] buffer = new byte[64 * 1024];

                 while ((b = contentStream.Stream.Read(buffer, 0, buffer.Length)) > 0)

                 {

                     stream.Write(buffer, 0, b);

diff --git a/DotCMIS/binding/converter.cs b/DotCMIS/binding/converter.cs
index 8d886cc..c542709 100644
--- a/DotCMIS/binding/converter.cs
+++ b/DotCMIS/binding/converter.cs
@@ -1697,7 +1697,7 @@
                 else

                 {

                     MemoryStream memStream = new MemoryStream();

-                    byte[] buffer = new byte[4096];

+                    byte[] buffer = new byte[64 * 1024];

                     int bytes;

                     while ((bytes = contentStream.Stream.Read(buffer, 0, buffer.Length)) > 0)

                     {