示例#1
0
        public IActionResult GetFile(string appName, string filePath)
        {
            try
            {
                var alias        = _tenantResolver.GetAlias();
                var fullFilePath = ContentFileHelper.GetFilePath(_hostingEnvironment.ContentRootPath, alias, Route, appName, filePath);
                if (string.IsNullOrEmpty(fullFilePath))
                {
                    return(NotFound());
                }

                var fileBytes = System.IO.File.ReadAllBytes(fullFilePath);
                var mimeType  = ContentFileHelper.GetMimeType(fullFilePath);

                return(mimeType.StartsWith("image") ? File(fileBytes, mimeType) :
                       new FileContentResult(fileBytes, mimeType)
                {
                    FileDownloadName = Path.GetFileName(fullFilePath)
                });
            }
            catch
            {
                return(NotFound());
            }
        }