• .net core 2.0 虚拟目录下载 Android Apk 等文件


    当Android 文件 Apk 放在Asp.net core wwwroot 虚拟目录下面、访问是 404,设置Content-Type类型

    app.UseStaticFiles();
    
                //设置实际目录与虚拟目录  
                app.UseStaticFiles(new StaticFileOptions
                {
                    FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), @"wwwroot/Files")),
                    RequestPath = new PathString("/jfiles"),
                 
                    //设置Android APK 下载
                    ContentTypeProvider = new FileExtensionContentTypeProvider(new Dictionary<string, string>
                    {
                        { ".apk","application/vnd.android.package-archive"},
                        { ".nupkg","application/zip"}
                    })
                });
    app.UseStaticFiles(new StaticFileOptions()
    {
        ContentTypeProvider = new FileExtensionContentTypeProvider()
        {
            Mappings = {[".glb"] = "application/octect-stream"}
        }
    });
  • 相关阅读:
    (2/24) 快速上手一个webpack的demo
    (1/24) 认识webpack
    module.exports 、exports、export、export default的区别
    Git同时提交到多个远程仓库
    @codeforces
    @loj
    @bzoj
    @loj
    @bzoj
    @bzoj
  • 原文地址:https://www.cnblogs.com/w2011/p/10094760.html
Copyright © 2020-2023  润新知