Raven.Storage.Managed.AttachmentsStorageActions.GetAttachment C# (CSharp) Method

GetAttachment() public method

public GetAttachment ( string key ) : Attachment
key string
return Attachment
		public Attachment GetAttachment(string key)
		{
			var attachmentPosition = Viewer.Attachments.FindValue(key);
			if (attachmentPosition == null)
				return null;
			Reader.Position = attachmentPosition.Value;
			var metadata = JObject.Load(new BsonReader(Reader));
			var size = BinaryReader.Read7BitEncodedInt();
			return new Attachment
			{
				Metadata = metadata,
				Etag = new Guid(metadata.Value<string>("@etag")),
				Data = BinaryReader.ReadBytes(size)
			};
		}
	}