06-15-2009 06:57 AM
06-15-2009 07:35 AM
06-24-2009 02:01 AM
06-24-2009 04:23 AM
06-25-2009 02:49 AM
…
url = "http://$SERVER:$PORT/alfresco/upload/workspace/SpacesStore/$NUUID/$FILENAME?ticket=$TICKET";
…
HttpWebResponse response = null;
HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
request.Method = "PUT";
request.SendChunked = true;
Stream requestStream = request.GetRequestStream();
CopyStream(contentStream, requestStream);
requestStream.Flush();
requestStream.Close();
…
//CopyStream body
…
int bufferSize = Config.Configuration.BUFFER_SIZE, rest = 0;
byte[] buffer = new byte[bufferSize];
while ((rest = source.Read(buffer, 0, bufferSize)) > 0)
{
destination.Write(buffer, 0, rest);//here is the point where Exception occurs!!!
destination.Flush();
}
…
06-25-2009 04:50 AM
06-25-2009 06:09 AM
/// <summary>
/// Copies the source to destination stream, iteratively, using an byte[] buffer with customizable length.
/// The length of the byte[] is given by Config.Configuration.BUFFER_SIZE.
/// IMPORTANT: it dosen't close nor dispose any of the given streams. It just flushes the destination for each successfuly writed byte[].
/// </summary>
/// <param name="source">The source stream to copy from</param>
/// <param name="destination">The destination stream to copy into</param>
/// <returns>true if operation successfully ended</returns>
public static bool CopyStream(Stream source, Stream destination)
{
bool success = true;
try
{
int bufferSize = Config.Configuration.BUFFER_SIZE, rest = 0;
byte[] buffer = new byte[bufferSize];
while ((rest = source.Read(buffer, 0, bufferSize)) > 0)
{
destination.Write(buffer, 0, rest);
destination.Flush();
}
}
catch (Exception e)
{
//logger.ERR(e);
success = false; ;
}
return success;
}
public class Configuration
{
#region buffer size
/// <summary>
/// Stores the buffer size used for general stream-bytes operations, to avoid system memory limitation issues
/// </summary>
private static int _bufferSize = 0;
/// <summary>
/// accessor for the buffer size. The default value is 1024 if no customized provided (via properties)
/// </summary>
public static int BUFFER_SIZE
{
get
{
if (_bufferSize == 0)//no value set into the properties
{
_bufferSize = 1024;
}
return _bufferSize;
}
}
#endregion //buffer size
}
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.