src/YL.Utils/Files/ContentType.cs

(开头部分) 36KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using Microsoft.AspNetCore.StaticFiles;
using System;
using System.Collections.Generic;
using System.Linq;
using YL.Utils.Check;

namespace YL.Utils.Files
{
    public class ContentType
    {
        public const string ContentTypeFile = "application/octet-stream";
        public const string ContentTypeExcel = "application/ms-excel";
        public const string ContentTypeJson = "application/json";
        public const string ContentTypeFrom = "application/x-www-form-urlencoded";
        public const string ContentTypeXml = "text/xml";
        public const string ContentTypeXml2 = "application/xml";
        public const string ContentTypeHtml = "text/html";
        public const string ContentTypeCss = "text/css";
        public const string ContentTypePpt = "application/x-ppt";
        public const string ContentTypeApk = "application/vnd.android.package-archive";
        public const string ContentTypeIpa = "application/vnd.iphone";
        public const string ContentTypeImg = "image/svg+xml";
        public const string ContentTypeSSE = "text/event-stream";//Server-Sent Events
        public const string CacheControl = "no-cache";
        public const string Connection = "keep-alive";

        public static IDictionary<string, string> GetContentTypes
        {
            get
            {
                var provider = new FileExtensionContentTypeProvider();
                var memi = provider.Mappings;
                return memi;
            }
        }

        //https://github.com/samuelneff/MimeTypeMap
        private static readonly Lazy<IDictionary<string, string>> _mappings = new Lazy<IDictionary<string, string>>(BuildMappings);

        private static IDictionary<string, string> BuildMappings()
        {
            var mappings = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase) {

                #region Big freaking list of mime types

                // maps both ways,
                // extension -> mime type
                //   and
                // mime type -> extension
                //
                // any mime types on left side not pre-loaded on right side, are added automatically
                // some mime types can map to multiple extensions, so to get a deterministic mapping,
                // add those to the dictionary specifcially
                //
                // combination of values from Windows 7 Registry and
                // from C:\Windows\System32\inetsrv\config\applicationHost.config
                // some added, including .7z and .dat
                //
                // Some added based on http://www.iana.org/assignments/media-types/media-types.xhtml
                // which lists mime types, but not extensions
后面还有 711 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。