예제 #1
0
        /// <summary>
        /// 如果uri是网络url则使用此方法
        /// </summary>
        /// <param name="fop">文件处理命令</param>
        /// <param name="url">资源URL</param>
        /// <returns>处理结果</returns>
        public HttpResult DfopUrl(string fop, string url)
        {
            HttpResult result     = new HttpResult();
            string     scheme     = this.config.UseHttps ? "https://" : "http://";
            string     encodedUrl = StringHelper.UrlEncode(url);
            string     dfopUrl    = string.Format("{0}{1}/dfop?fop={2}&url={3}", scheme, Config.DefaultApiHost, fop, encodedUrl);
            string     token      = auth.CreateManageToken(dfopUrl);

            result = httpManager.Post(dfopUrl, token, true);
            return(result);
        }
예제 #2
0
        /// <summary>
        /// 数据处理
        /// </summary>
        /// <param name="bucket">空间</param>
        /// <param name="key">空间文件的key</param>
        /// <param name="fops">操作(命令参数)</param>
        /// <param name="pipeline">私有队列</param>
        /// <param name="notifyUrl">通知url</param>
        /// <param name="force">forece参数</param>
        /// <returns>pfop操作返回结果,正确返回结果包含persistentId</returns>
        public PfopResult Pfop(string bucket, string key, string fops, string pipeline, string notifyUrl, bool force)
        {
            PfopResult result = new PfopResult();

            try
            {
                string pfopUrl = string.Format("{0}/pfop/", this.config.ApiHost(this.mac.AccessKey, bucket));

                StringBuilder sb = new StringBuilder();
                sb.AppendFormat("bucket={0}&key={1}&fops={2}", Util.StringHelper.UrlEncode(bucket), StringHelper.UrlEncode(key),
                                StringHelper.UrlEncode(fops));
                if (!string.IsNullOrEmpty(notifyUrl))
                {
                    sb.AppendFormat("&notifyURL={0}", StringHelper.UrlEncode(notifyUrl));
                }
                if (force)
                {
                    sb.Append("&force=1");
                }
                if (!string.IsNullOrEmpty(pipeline))
                {
                    sb.AppendFormat("&pipeline={0}", pipeline);
                }
                byte[] data  = Encoding.UTF8.GetBytes(sb.ToString());
                string token = auth.CreateManageToken(pfopUrl, data);

                HttpResult hr = httpManager.PostForm(pfopUrl, data, token);
                result.Shadow(hr);
            }
            catch (QiniuException ex)
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendFormat("[{0}] [pfop] Error:  ", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.ffff"));
                Exception e = ex;
                while (e != null)
                {
                    sb.Append(e.Message + " ");
                    e = e.InnerException;
                }
                sb.AppendLine();

                result.Code     = ex.HttpResult.Code;
                result.RefCode  = ex.HttpResult.Code;
                result.Text     = ex.HttpResult.Text;
                result.RefText += sb.ToString();
            }

            return(result);
        }