Esempio n. 1
0
        //private void init()
        //{
        //    using (StreamReader sr = new StreamReader("Template/JsonFormat.html"))
        //    {
        //        prefopResultTemplate = sr.ReadToEnd();
        //    }
        //}

        private void PfopButton_Click(object sender, RoutedEventArgs e)
        {
            string bucket = this.BucketTextBox.Text.Trim();
            string key    = this.KeyTextBox.Text.Trim();
            string fops   = this.FopsTextBox.Text.Trim();

            if (bucket.Length == 0 || key.Length == 0 || fops.Length == 0)
            {
                return;
            }
            #region FIX_PFOP_ZONE_CONFIG
            try
            {
                Config.AutoZone(AppSettings.Default.ACCESS_KEY, bucket, false);
                this.TextBox_PrefopResultText.Clear();
            }
            catch (Exception ex)
            {
                this.TextBox_PfopResultText.Text = "配置出错,请检查您的输入(如密钥/scope/bucket等)\r\n" + ex.Message;
                return;
            }
            #endregion FIX_PFOP_ZONE_CONFIG
            string pipeline  = this.PipelineTextBox.Text.Trim();
            bool   force     = this.ForceCheckBox.IsChecked.Value;
            string notifyURL = this.NotifyURLTextBox.Text.Trim();

            Task.Factory.StartNew(() =>
            {
                Mac mac               = new Mac(AppSettings.Default.ACCESS_KEY, AppSettings.Default.SECRET_KEY);
                OperationManager ox   = new OperationManager(mac);
                PfopResult pfopResult = ox.Pfop(bucket, key, fops.Split(';'), pipeline, notifyURL, force);

                Dispatcher.BeginInvoke((Action)(() =>
                {
                    if (pfopResult.PersistentId != null)
                    {
                        this.PersistentIdTextBox.Text = pfopResult.PersistentId;
                    }

                    this.TextBox_PfopResultText.Text = pfopResult.Text;
                    this.TextBox_PfopResultString.Text = pfopResult.ToString();
                }));
            });
        }
Esempio n. 2
0
        public void PfopTest()
        {
            string           saveMp4Entry  = Base64.UrlSafeBase64Encode(Bucket + ":avthumb_test_target.mp4");
            string           saveJpgEntry  = Base64.UrlSafeBase64Encode(Bucket + ":vframe_test_target.jpg");
            string           avthumbMp4Fop = "avthumb/mp4|saveas/" + saveMp4Entry;
            string           vframeJpgFop  = "vframe/jpg/offset/1|saveas/" + saveJpgEntry;
            string           fops          = string.Join(";", new string[] { avthumbMp4Fop, vframeJpgFop });
            Mac              mac           = new Mac(AccessKey, SecretKey);
            Config           config        = new Config();
            OperationManager manager       = new OperationManager(mac, config);
            string           pipeline      = "sdktest";
            string           notifyUrl     = "http://api.example.com/qiniu/pfop/notify";
            string           key           = "qiniu.mp4";
            bool             force         = true;
            PfopResult       pfopRet       = manager.Pfop(Bucket, key, fops, pipeline, notifyUrl, force);

            if (pfopRet.Code != (int)HttpCode.OK)
            {
                Assert.Fail("pfop error: " + pfopRet.ToString());
            }
            Console.WriteLine(pfopRet.PersistentId);
        }