Пример #1
0
        private void SkipAttachmentStream(BlittableJsonReaderObject data)
        {
            if (data.TryGet(nameof(AttachmentName.Hash), out LazyStringValue _) == false ||
                data.TryGet(nameof(AttachmentName.Size), out long size) == false ||
                data.TryGet(nameof(DocumentItem.AttachmentStream.Tag), out LazyStringValue _) == false)
            {
                throw new ArgumentException($"Data of attachment stream is not valid: {data}");
            }

            while (size > 0)
            {
                var sizeToRead = (int)Math.Min(32 * 1024, size);
                var read       = _parser.Skip(sizeToRead);
                if (read.Done == false)
                {
                    var read2 = _peepingTomStream.Read(_buffer.Buffer.Array, _buffer.Buffer.Offset, _buffer.Length);
                    if (read2 == 0)
                    {
                        throw new EndOfStreamException("Stream ended without reaching end of stream content");
                    }

                    _parser.SetBuffer(_buffer, 0, read2);
                }
                size -= read.BytesRead;
            }
        }