internal static ObjectId Upload(DeveelDbConnection connection, DeveelDbLob lob) { if (connection == null) { throw new InvalidOperationException("An open connection is required to upload the LOB"); } var objId = connection.CreateLargeObject(lob.Length); using (var channel = connection.OpenLargeObjectChannel(objId)) { const int bufferSize = 2048; var copyBuffer = new byte[bufferSize]; int readCount; long copyOffset = 0; lob.writeStream.Seek(0, SeekOrigin.Begin); while ((readCount = lob.writeStream.Read(copyBuffer, 0, bufferSize)) > 0) { channel.PushData(copyOffset, copyBuffer, readCount); copyOffset += readCount; } } return(objId); }
internal static ObjectId Upload(DeveelDbConnection connection, DeveelDbLob lob) { if (connection == null) throw new InvalidOperationException("An open connection is required to upload the LOB"); var objId = connection.CreateLargeObject(lob.Length); using (var channel = connection.OpenLargeObjectChannel(objId)) { const int bufferSize = 2048; var copyBuffer = new byte[bufferSize]; int readCount; long copyOffset = 0; lob.writeStream.Seek(0, SeekOrigin.Begin); while ((readCount = lob.writeStream.Read(copyBuffer, 0, bufferSize)) > 0) { channel.PushData(copyOffset, copyBuffer, readCount); copyOffset += readCount; } } return objId; }