/// <inheritdoc/> public async Task <byte[]> ResolveImageAsync(HttpContext context, ILogger logger) { // Path has already been correctly parsed before here. var file = await _mediaStore.MapFileAsync(context.Request.Path); byte[] buffer; // Check to see if the file exists. if (file == null) { return(null); } using (Stream stream = file.CreateReadStream()) { // Buffer is returned to the pool in the middleware buffer = BufferDataPool.Rent((int)stream.Length); await stream.ReadAsync(buffer, 0, (int)stream.Length); } return(buffer); }