Exemplo n.º 1
0
        private void reloadBuckets()
        {
            BucketsResult bucketsResult = bucketManager.Buckets(true);

            if (bucketsResult.Code == 200)
            {
                //todo:保存ak&sk

                if (File.Exists("QiNiuClientCfg.Json"))
                {
                    File.Delete("QiNiuClientCfg.Json");
                }



                string json = JsonConvert.SerializeObject(qiNiuClientCfg);
                File.WriteAllText("QiNiuClientCfg.Json", json);


                List <string> buckets = bucketsResult.Result;

                Dispatcher.Invoke(new Action(() =>
                {
                    this.SyncTargetBucketsComboBox.ItemsSource = buckets;
                    BtnConnet.IsEnabled = true;
                    pb1.Visibility      = Visibility.Hidden;
                    MessageBox.Show("连接成功!");
                }));
            }
        }
Exemplo n.º 2
0
        private void textBoxSK_TextChanged(object sender, EventArgs e)
        {
            string AK = this.textBoxAK.Text;
            string SK = this.textBoxSK.Text;

            if (String.IsNullOrEmpty(AK) || String.IsNullOrEmpty(SK))
            {
                MessageBox.Show("请设置AK和SK");
                this.textBoxAK.Focus();
            }
            else
            {
                Mac           mac          = new Mac(AK, SK);
                BucketManager bucketManger = new BucketManager(mac);
                BucketsResult bucketResult = bucketManger.Buckets();
                if (bucketResult.Code == 200)
                {
                    for (int i = 0; i < bucketResult.Result.Count; i++)
                    {
                        comboBoxBuckets.Items.Add(bucketResult.Result[i]);
                    }
                    this.comboBoxBuckets.SelectedIndex = 0;
                }
                else
                {
                    MessageBox.Show("认证失败,请重新设置AK和SK");
                    this.textBoxAK.Focus();
                }
            }
        }
Exemplo n.º 3
0
        public static async Task <List <string> > GetBuckets(bool isShare = true)
        {
#if MOCK
            return(new List <string>
            {
                "Bucket1",
                "Bucket2",
                "Bucket3"
            });
#else
            var bucketManager = new BucketManager(_currentMac, _config);
            var queryResult   = await Task.Factory.StartNew(() =>
            {
                var allBuckets = bucketManager.Buckets(true);
                return(allBuckets);
            });

            if (queryResult?.Result == null)
            {
                return(new List <string>());
            }

            return(queryResult.Result);
#endif
        }
Exemplo n.º 4
0
        /// <summary>
        /// 列举所有的bucket
        /// </summary>
        public static void buckets()
        {
            Mac           mac = new Mac(Settings.AccessKey, Settings.SecretKey);
            BucketManager bm  = new BucketManager(mac);

            var result = bm.Buckets();

            Console.WriteLine(result);
        }
Exemplo n.º 5
0
        public void BucketsTest()
        {
            Mac           mac    = new Mac(AccessKey, SecretKey);
            BucketManager target = new BucketManager(mac);

            BucketsResult result = target.Buckets();

            Assert.AreEqual((int)HttpCode.OK, result.Code);
        }
Exemplo n.º 6
0
        private void reloadBuckets()
        {
            BucketsResult bucketsResult = bucketManager.Buckets(true);

            if (bucketsResult.Code == 200)
            {
                //todo:保存ak&sk

                if (File.Exists("QiNiuClientCfg.Json"))
                {
                    File.Delete("QiNiuClientCfg.Json");
                }



                string json = JsonConvert.SerializeObject(qiNiuClientCfg);
                File.WriteAllText("QiNiuClientCfg.Json", json);


                List <string> buckets = bucketsResult.Result;

                Dispatcher.Invoke(new Action(() =>
                {
                    this.SyncTargetBucketsComboBox.ItemsSource = buckets;
                    BtnConnet.IsEnabled = true;
                    pb1.Visibility      = Visibility.Hidden;
                    if (!string.IsNullOrWhiteSpace(TxtAK.Text.Trim()))
                    {
                        string ak = TxtAK.Text.Trim();
                        if (ak.Length >= 40 && !ak.Contains("*"))
                        {
                            TxtAK.Text = ak.Substring(0, 4) + "********************************" + ak.Substring(ak.Length - 5, 4);
                        }
                    }
                    if (!string.IsNullOrWhiteSpace(TxtSk.Text.Trim()))
                    {
                        string sk = TxtSk.Text.Trim();
                        if (sk.Length >= 40 && !sk.Contains("*"))
                        {
                            TxtSk.Text = sk.Substring(0, 4) + "********************************" + sk.Substring(sk.Length - 5, 4);
                        }
                    }
                    MessageBox.Show("连接成功!");
                }));
            }
            else
            {
                Dispatcher.Invoke(new Action(() =>
                {
                    BtnConnet.IsEnabled = true;
                    pb1.Visibility      = Visibility.Hidden;

                    MessageBox.Show("连接失败!");
                }));
            }
            progressbarNeedStop = true;
        }
Exemplo n.º 7
0
        private void QiniuGui_Load(object sender, EventArgs e)
        {
            //获取所有Buckets
            var    appSettings = ConfigurationManager.AppSettings;
            string AK          = appSettings["AK"];
            string SK          = appSettings["SK"];

            mac = new Mac(AK, SK);
            BucketManager bucketManger = new BucketManager(mac);
            BucketsResult bucketResult = bucketManger.Buckets();

            for (int i = 0; i < bucketResult.Result.Count; i++)
            {
                comboBoxBuckets.Items.Add(bucketResult.Result[i]);
            }
        }
        public async Task BucketsTest()
        {
            var config = new Config {
                Zone = Zone.ZoneCnEast
            };
            var mac           = new Mac(AccessKey, SecretKey);
            var bucketManager = new BucketManager(mac, config);
            var ret           = await bucketManager.Buckets(true);

            if (ret.Code != (int)HttpCode.OK)
            {
                Assert.True(false, "buckets error: " + ret);
            }

            foreach (var bucket in ret.Result)
            {
                Console.WriteLine(bucket);
            }
        }
Exemplo n.º 9
0
        public void BucketsTest()
        {
            Config config = new Config();

            config.Zone = Zone.ZONE_CN_East;
            Mac           mac           = new Mac(AccessKey, SecretKey);
            BucketManager bucketManager = new BucketManager(mac, config);
            BucketsResult ret           = bucketManager.Buckets(true);

            if (ret.Code != (int)HttpCode.OK)
            {
                Assert.Fail("buckets error: " + ret.ToString());
            }

            foreach (string bucket in ret.Result)
            {
                Console.WriteLine(bucket);
            }
        }
Exemplo n.º 10
0
        static void Main(string[] args)
        {
            Auth   auth   = EnvUtility.EnvAuth();
            Config config = EnvUtility.EnvConfig();

            BucketManager bm = new BucketManager(auth, config);

            // 枚举所有 Buckets
            HttpResult result = bm.Buckets();

            Console.WriteLine("---Buckets---\n{0}", result.ToString());
            if ((int)HttpStatusCode.OK == result.Code)
            {
                JObject jo      = JObject.Parse(result.Text);
                var     buckets = jo["buckets"];
                Console.WriteLine("{0} Buckets found:", buckets.Count());
                int i = 0;
                foreach (var bucket in buckets)
                {
                    // 打印 Bucket 名字
                    Console.WriteLine("{0}\t{1}", ++i, bucket["name"].ToString());
                }
            }

            // BucketManager 还有很多函数,以下示范比较粗糙,您需要自己改改!
            result = bm.BucketList("umu618-docs", 0, null, 1);
            Console.WriteLine("---BucketList---\n{0}", result.ToString());

            result = bm.BucketStat("chentemp|umu618-docs", "2017-07-01", "2017-09-01");
            Console.WriteLine("---BucketStat---\n{0}", result.ToString());

            result = bm.Stat("umu618-docs", "Go.pdf");
            Console.WriteLine("---Stat---\n{0}", result.ToString());

            string[] keys = { "Go.pdf" };
            result = bm.Prefetch("umu618-docs", keys);
            Console.WriteLine("---Prefetch---\n{0}", result.ToString());

            result = bm.ImageInfo("http://images.w.wcsapi.biz.matocloud.com/1.png");
            Console.WriteLine("---ImageInfo---\n{0}", result.ToString());

            result = bm.Exif("http://chentemp.w.wcsapi.biz.matocloud.com/IMG_1140.JPG");
            Console.WriteLine("---Exif---\n{0}", result.ToString());

            result = bm.AvInfo("http://images.w.wcsapi.biz.matocloud.com/1.mp4");
            Console.WriteLine("---AvInfo---\n{0}", result.ToString());

            result = bm.AvInfo2("http://images.w.wcsapi.biz.matocloud.com/1.mp4");
            Console.WriteLine("---AvInfo2---\n{0}", result.ToString());

            result = bm.Delete("umu618-docs", "/temp/");
            Console.WriteLine("---Delete---\n{0}", result.ToString());

            result = bm.Move("umu618-docs", "Go.pdf", "umu618-docs", "golang/Go.pdf");
            Console.WriteLine("---Move---\n{0}", result.ToString());

            result = bm.Copy("umu618-docs", "data.txt", "umu618-docs", "data.txt");
            Console.WriteLine("---Copy---\n{0}", result.ToString());

            result = bm.Decompression("umu618-docs", "各种录音程序.7z", "7z", "umu618-docs:exe", "umu618-docs:exe/UMU.list");
            Console.WriteLine("---Decompression---\n{0}", result.ToString());

            Dictionary <string, string> d = new Dictionary <string, string>();

            d.Add("umu618-docs:/", "umu618-docs:UMU.list");
            d.Add("umu618-docs:temp", "umu618-docs:temp/UMU.list");
            result = bm.Decompression("umu618-docs", "各种录音程序.7z", "7z", d);
            Console.WriteLine("---Decompression---\n{0}", result.ToString());

            result = bm.PersistentStatus("e534f75d41534f468a7efe9a51dc90ad");
            Console.WriteLine("---PersistentStatus---\n{0}", result.ToString());

            result = bm.SetDeadline("umu618-docs", "Go.pdf", -1);
            Console.WriteLine("---SetDeadline---\n{0}", result.ToString());
        }