// protected methods protected override void CloseImplementation(CancellationToken cancellationToken) { if (_checkMD5 && _position == FileInfo.Length) { var md5 = BsonUtils.ToHexString(_md5.GetHashAndReset()); if (!md5.Equals(FileInfo.MD5, StringComparison.OrdinalIgnoreCase)) { #pragma warning disable 618 throw new GridFSMD5Exception(_idAsBsonValue); #pragma warning restore } } }
private BsonDocument CreateFilesCollectionDocument() { var uploadDateTime = DateTime.UtcNow; return(new BsonDocument { { "_id", _idAsBsonValue }, { "length", _length }, { "chunkSize", _chunkSizeBytes }, { "uploadDate", uploadDateTime }, { "md5", BsonUtils.ToHexString(_md5.GetHashAndReset()) }, { "filename", _filename }, { "contentType", _contentType, _contentType != null }, { "aliases", () => new BsonArray(_aliases.Select(a => new BsonString(a))), _aliases != null }, { "metadata", _metadata, _metadata != null } }); }
// private methods private void CloseHelper() { if (!_closed) { _closed = true; if (_checkMD5 && _position == FileInfo.Length) { var md5 = BsonUtils.ToHexString(_md5.GetHashAndReset()); if (!md5.Equals(FileInfo.MD5, StringComparison.OrdinalIgnoreCase)) { #pragma warning disable 618 throw new GridFSMD5Exception(_idAsBsonValue); #pragma warning restore } } } }