상속: Qiniu.Http.HttpResult
예제 #1
0
        public PfopResult pfop(string bucket, string key, string fops, string pipeline, string notifyUrl, bool force)
        {
            PfopResult pfopResult = null;

            Dictionary <string, string[]> pfopParams = new Dictionary <string, string[]>();

            pfopParams.Add("bucket", new string[] { bucket });
            pfopParams.Add("key", new string[] { key });
            pfopParams.Add("fops", new string[] { fops });
            if (!string.IsNullOrEmpty(notifyUrl))
            {
                pfopParams.Add("notifyURL", new string[] { notifyUrl });
            }
            if (force)
            {
                pfopParams.Add("force", new string[] { "1" });
            }
            if (!string.IsNullOrEmpty(pipeline))
            {
                pfopParams.Add("pipeline", new string[] { pipeline });
            }

            string pfopUrl = Config.ZONE.ApiHost + "/pfop/";

            string accessToken = Auth.createManageToken(pfopUrl, Encoding.UTF8.GetBytes(StringUtils.urlValuesEncode(pfopParams)), this.Mac);
            Dictionary <string, string> pfopHeaders = new Dictionary <string, string>();

            pfopHeaders.Add("Authorization", accessToken);

            CompletionHandler pfopCompletionHandler = new CompletionHandler(delegate(ResponseInfo respInfo, string response)
            {
                if (respInfo.isOk())
                {
                    pfopResult = StringUtils.jsonDecode <PfopResult>(response);
                }
                else
                {
                    pfopResult = new PfopResult();
                }
                pfopResult.ResponseInfo = respInfo;
                pfopResult.Response     = response;
            });

            this.mHttpManager.postForm(pfopUrl, pfopHeaders, pfopParams, pfopCompletionHandler);
            return(pfopResult);
        }
예제 #2
0
파일: Pfop.cs 프로젝트: qiniu/csharp-sdk
        public PfopResult pfop(string bucket, string key, string fops, string pipeline, string notifyUrl, bool force)
        {
            PfopResult pfopResult = null;

            Dictionary<string, string[]> pfopParams = new Dictionary<string, string[]>();
            pfopParams.Add("bucket", new string[] { bucket });
            pfopParams.Add("key", new string[] { key });
            pfopParams.Add("fops", new string[] { fops });
            if (!string.IsNullOrEmpty(notifyUrl))
            {
                pfopParams.Add("notifyURL", new string[] { notifyUrl });
            }
            if (force)
            {
                pfopParams.Add("force", new string[] { "1" });
            }
            if (!string.IsNullOrEmpty(pipeline))
            {
                pfopParams.Add("pipeline", new string[] { pipeline });
            }

            string pfopUrl = Config.ZONE.ApiHost + "/pfop/";

            string accessToken = Auth.createManageToken(pfopUrl, Encoding.UTF8.GetBytes(StringUtils.urlValuesEncode(pfopParams)), this.Mac);
            Dictionary<string, string> pfopHeaders = new Dictionary<string, string>();
            pfopHeaders.Add("Authorization", accessToken);

            CompletionHandler pfopCompletionHandler = new CompletionHandler(delegate (ResponseInfo respInfo, string response)
            {
                if (respInfo.isOk())
                {
                    pfopResult = StringUtils.jsonDecode<PfopResult>(response);
                }
                else
                {
                    pfopResult = new PfopResult();
                }
                pfopResult.ResponseInfo = respInfo;
                pfopResult.Response = response;
            });

            this.mHttpManager.postForm(pfopUrl, pfopHeaders, pfopParams, pfopCompletionHandler);
            return pfopResult;
        }
예제 #3
0
        public PfopResult pfop()
        {
            PfopResult pfopResult = null;

            PostArgs postArgs = new PostArgs();
            postArgs.Params.Add("bucket", this.Bucket);
            postArgs.Params.Add("key", this.Key);
            postArgs.Params.Add("fops", this.Fops);
            if (!string.IsNullOrEmpty(this.NotifyURL))
            {
                postArgs.Params.Add("notifyURL", this.NotifyURL);
            }
            if (this.Force)
            {
                postArgs.Params.Add("force", "1");
            }
            if (!string.IsNullOrEmpty(this.Pipeline))
            {
                postArgs.Params.Add("pipeline", this.Pipeline);
            }

            string apiAddress = Config.API_HOST + "/pfop/";

            string auth = Auth.createManageToken(apiAddress, Encoding.UTF8.GetBytes(StringUtils.urlParamsJoin(postArgs.Params)), this.Mac);

            //set http manager
            this.httpManager.PostArgs = postArgs;
            this.httpManager.setAuthHeader(auth);
            this.httpManager.CompletionHandler = new CompletionHandler(delegate(ResponseInfo respInfo, string response)
            {
                if (respInfo.isOk())
                {
                    pfopResult = StringUtils.jsonDecode<PfopResult>(response);
                }
                else
                {
                    pfopResult = new PfopResult();
                }
                pfopResult.ResponseInfo = respInfo;
                pfopResult.Response = response;
            });
            this.httpManager.post(apiAddress);
            return pfopResult;
        }