net core 3.1 open file

[HttpGet]
        public IActionResult GetFile(string filepath)
        {
            if (string.IsNullOrEmpty(filepath)) filepath = "D:\\ABC.log";
            var provider = new FileExtensionContentTypeProvider();
            FileInfo fileInfo = new FileInfo(filepath);
            var ext = fileInfo.Extension;
            new FileExtensionContentTypeProvider().Mappings.TryGetValue(ext,out var contenttype);
            return File(System.IO.File.ReadAllBytes(filepath), contenttype ?? "application/octet-stream", fileInfo.Name);
        }

 

net core 3.1 open file

上一篇:数据结构:优先队列和堆(JS篇)


下一篇:SQL注入之MYSQL