/// <summary>
 /// Creates a new instance of <see cref="CallbackHeaderBuilder" />
 /// </summary>
 /// <param name="callbackUrl">callback url</param>
 /// <param name="callbackHost"> callback host</param>
 /// <param name="callbackBody">callback body</param>
 /// <param name="callbackBodyType">callback body type</param>
 public CallbackHeaderBuilder(string callbackUrl, string callbackHost, string callbackBody, CallbackBodyType callbackBodyType)
 {
     CallbackUrl      = callbackUrl;
     CallbackHost     = callbackHost;
     CallbackBody     = callbackBody;
     CallbackBodyType = callbackBodyType;
 }
 /// <summary>
 /// Creates a new instance of <see cref="CallbackHeaderBuilder" />
 /// </summary>
 /// <param name="callbackUrl">callback url</param>
 /// <param name="callbackBody">callback body</param>
 public CallbackHeaderBuilder(string callbackUrl, string callbackBody)
 {
     CallbackUrl      = callbackUrl;
     CallbackHost     = null;
     CallbackBody     = callbackBody;
     CallbackBodyType = CallbackBodyType.Url;
 }
Beispiel #3
0
        /// <summary>
        /// 得到上传策略
        /// </summary>
        /// <param name="uploadPersistentOps">上传策略</param>
        /// <returns></returns>
        protected virtual UploadPersistentOps GetUploadPersistentOps(UploadPersistentOps uploadPersistentOps)
        {
            if (uploadPersistentOps == null)
            {
                uploadPersistentOps = new UploadPersistentOps();
            }

            if (uploadPersistentOps.IsUseHttps == null)
            {
                uploadPersistentOps.IsUseHttps = _qiNiuConfig.IsUseHttps;
            }

            if (uploadPersistentOps.UseCdnDomains == null)
            {
                uploadPersistentOps.UseCdnDomains = _qiNiuConfig.UseCdnDomains;
            }

            if (uploadPersistentOps.IsAllowOverlap == null)
            {
                uploadPersistentOps.IsAllowOverlap = _qiNiuConfig.IsAllowOverlap;
            }

            if (uploadPersistentOps.ChunkUnit == null)
            {
                uploadPersistentOps.ChunkUnit = _qiNiuConfig.ChunkUnit;
            }

            if ((uploadPersistentOps.EnableCallback == null && _qiNiuConfig.EnableCallback) ||
                uploadPersistentOps.EnableCallback == true)
            {
                if (uploadPersistentOps.EnableCallback == null && _qiNiuConfig.EnableCallback)
                {
                    uploadPersistentOps.SetCallBack(CallbackBodyType
                                                    .FromValue <CallbackBodyType>(_qiNiuConfig.CallbackBodyType)
                                                    ?.Name ??
                                                    CallbackBodyType.Json.Name, _qiNiuConfig.CallbackHost,
                                                    _qiNiuConfig.CallbackUrl, _qiNiuConfig.CallbackBody);
                }
                else
                {
                    uploadPersistentOps.SetCallBack(uploadPersistentOps.CallbackBodyType,
                                                    uploadPersistentOps.CallbackHost, uploadPersistentOps.CallbackUrl,
                                                    uploadPersistentOps.CallbackBody);
                }
            }

            if (uploadPersistentOps.EnablePersistentNotifyUrl)
            {
                string persistentNotifyUrl = string.IsNullOrEmpty(uploadPersistentOps.PersistentNotifyUrl)
                    ? _qiNiuConfig.PersistentNotifyUrl
                    : uploadPersistentOps.PersistentNotifyUrl;
                uploadPersistentOps.SetPersistentNotifyUrl(persistentNotifyUrl);
            }

            if (uploadPersistentOps.EnablePersistentPipeline)
            {
                string persistentPipeline = string.IsNullOrEmpty(uploadPersistentOps.PersistentPipeline)
                    ? _qiNiuConfig.PersistentPipeline
                    : uploadPersistentOps.PersistentPipeline;
                uploadPersistentOps.SetPersistentPipeline(persistentPipeline);
            }

            return(uploadPersistentOps);
        }