zoukankan      html  css  js  c++  java
  • 七牛云-C#SDK-上传-前期准备

    1.创建一个asp.net core MVC 程序(这里随便

        这是一个空的程序

        

    2.创建UploadController

    3.添加引用

    Install-Package Newtonsoft.Json //用来处理json
    Install-Package Qiniu //七牛云

    4.获取七牛云上传的配置信息   AK & SK & Bucket

    AK & SK : 个人中心------>密钥管理

     Bucket:就是创建对象存储空间时取的名字

    把上面的配置信息放在appsetting.json中,方便读取 

    下面的配置还有一个单独提出来的链接:https://www.cnblogs.com/mi21/p/10907948.html

    5.在appsetting.json 文件中添加自定义配置

    {
      "Logging": {
        "LogLevel": {
          "Default": "Warning"
        }
      },
      "AllowedHosts": "*",
    
      "Qny": {
        "qiniuyunAK": "AK", //ak
        "qiniuyunSK": "SK", //sk
        "qiniuyunBucket": "空间名称", //存储空间名称
        "prefixPath": "http://upload.qiniup.com" //七牛云地址
      }
    }

    6.创建一个Model 

    public class QnySetting
        {
            public string qiniuyunAK { get; set; }
            public string qiniuyunSK { get; set; }
            public string qiniuyunBucket { get; set; }
            public string prefixPath { get; set; }
        }

    7.在Startup.cs中注册服务

    services.Configure<QnySetting>(this.Configuration.GetSection("Qny"));

    8.在xxxcontroller中使用

    private readonly QnySetting _Quy;
            public UploadController(IOptions<QnySetting> Quy)
            {
                _Quy = Quy.Value;
            }
            public IActionResult Index()
            {
                Console.WriteLine(_Quy);
                return View();
            }

     到这里前期的准备就完了,继续了解请看:https://www.cnblogs.com/mi21/p/10908194.html 

  • 相关阅读:
    php 数组
    条件语句if else ,switch ,while ,do.while
    if..else 判断中的 Boolean()转换
    wampserver 集成环境
    sublime text 安装及使用
    vue tab切换
    SVG 基础
    gitosis管理员的密钥丢失解决办法
    源码安装MySQL
    Xshell远程登录
  • 原文地址:https://www.cnblogs.com/mi21/p/10904689.html
Copyright © 2011-2022 走看看