Esempio n. 1
0
        public override void Flush()
        {
            if (outTempStream == null ||
                outTempStream.Length == 0)
            {
                return;
            }

            try {
                long offset      = 0;
                var  buffer      = new byte[BufferSize];
                var  totalLength = outTempStream.Length;

                outTempStream.Seek(0, SeekOrigin.Begin);

                while (offset < totalLength)
                {
                    // Fill the buffer
                    int index     = 0;
                    int blockRead = (int)System.Math.Min((long)BufferSize, (totalLength - offset));
                    int toRead    = blockRead;
                    while (toRead > 0)
                    {
                        int count = outTempStream.Read(buffer, index, toRead);
                        if (count == 0)
                        {
                            break;
                        }

                        index  += count;
                        toRead -= count;
                    }

                    // Send the part of the streamable object to the database.
                    largeObject.Write(offset, buffer, blockRead);
                    // Increment the offset and upload the next part of the object.
                    offset += blockRead;
                }
            } finally {
                outTempStream.SetLength(0);
            }
        }
Esempio n. 2
0
 public void PushData(long offset, byte[] buffer, int length)
 {
     obj.Write(offset, buffer, length);
 }