Beispiel #1
0
        public object Get(GetIcon request)
        {
            var contentType = "image/" + Path.GetExtension(request.Filename).TrimStart('.').ToLower();

            var cacheLength = TimeSpan.FromDays(365);
            var cacheKey    = Request.RawUrl.GetMD5();

            return(_resultFactory.GetStaticResult(Request, cacheKey, null, cacheLength, contentType, () => Task.FromResult(_dlnaManager.GetIcon(request.Filename).Stream)));
        }
Beispiel #2
0
        public object Get(GetIcon request)
        {
            using (var response = _dlnaManager.GetIcon(request.Filename))
            {
                using (var ms = new MemoryStream())
                {
                    response.Stream.CopyTo(ms);

                    ms.Position = 0;
                    var bytes = ms.ToArray();

                    var contentType = "image/" + response.Format.ToString().ToLower();

                    var cacheLength = TimeSpan.FromDays(365);
                    var cacheKey    = Request.RawUrl.GetMD5();

                    return(_resultFactory.GetStaticResult(Request, cacheKey, null, cacheLength, contentType, () => Task.FromResult <Stream>(new MemoryStream(bytes))));
                    //return ResultFactory.GetResult(bytes, contentType);
                }
            }
        }