コード例 #1
0
        public async Task <ActionResult> DownloadFile()
        {
            var path     = Request.QueryString.ToString().TrimStart('?');
            var accessor = await FileAccessor.Create(path, User);

            if (!accessor.IsAllowed())
            {
                return(new UnauthorizedResult());
            }

            if (accessor.Blob.IsMedia())
            {
                return(await RangeFileContentResult.From(accessor.Blob));
            }
            else
            {
                return(await File(accessor.Blob));
            }
        }