C# 七牛云上传文件(CS桌面)

天下文章一大抄,看你抄到没抄到,菜鸟的我就只会这招了。

  static readonly string SK = "xxx";
        static readonly string Bucket = "fmis";
        static readonly string AK = "xxx";

 PutPolicy putPolicy = new PutPolicy();
            // 设置要上传的目标空间
            putPolicy.Scope = Bucket;      
 
            Mac mac = new Mac(AK, SK);
            string uploadToken = Auth.CreateUploadToken(mac, putPolicy.ToJsonString()); 



           

            Config c = new Config();


            
            PutExtra extra = new PutExtra();
            var putExtra = new PutExtra();
            FormUploader upLoader = new FormUploader(c);
           
            foreach (string s in richTextBox1.Lines)
            {
                if (s.Length > 0)
                {
                    Qiniu.Http.HttpResult result = upLoader.UploadFile(s, Path.GetFileName(s), uploadToken, extra);
                                        //if (result.StatusCode. != 200)

                                   MessageBox.Show(result.Code.ToString());
                }
            }

你可能感兴趣的:(c#)