QNConfiguration.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. //
  2. // QNConfiguration.h
  3. // QiniuSDK
  4. //
  5. // Created by bailong on 15/5/21.
  6. // Copyright (c) 2015年 Qiniu. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import "QNRecorderDelegate.h"
  10. #import "QNDns.h"
  11. #import "QNZone.h"
  12. /**
  13. * 断点上传时的分块大小
  14. */
  15. extern const UInt32 kQNBlockSize;
  16. /**
  17. * DNS默认缓存时间
  18. */
  19. extern const UInt32 kQNDefaultDnsCacheTime;
  20. /**
  21. * 转换为用户需要的url
  22. *
  23. * @param url 上传url
  24. *
  25. * @return 根据上传url算出代理url
  26. */
  27. typedef NSString * (^QNUrlConvert)(NSString *url);
  28. @class QNConfigurationBuilder;
  29. @class QNZone;
  30. @class QNReportConfig;
  31. /**
  32. * Builder block
  33. *
  34. * @param builder builder实例
  35. */
  36. typedef void (^QNConfigurationBuilderBlock)(QNConfigurationBuilder *builder);
  37. @interface QNConfiguration : NSObject
  38. /**
  39. * 存储区域
  40. */
  41. @property (copy, nonatomic, readonly) QNZone *zone;
  42. /**
  43. * 断点上传时的分片大小
  44. */
  45. @property (readonly) UInt32 chunkSize;
  46. /**
  47. * 如果大于此值就使用断点上传,否则使用form上传
  48. */
  49. @property (readonly) UInt32 putThreshold;
  50. /**
  51. * 上传失败时每个上传域名的重试次数,默认重试3次
  52. */
  53. @property (readonly) UInt32 retryMax;
  54. /**
  55. * 重试前等待时长,默认0.5s
  56. */
  57. @property (readonly) NSTimeInterval retryInterval;
  58. /**
  59. * 超时时间 单位 秒
  60. */
  61. @property (readonly) UInt32 timeoutInterval;
  62. /**
  63. * 是否使用 https,默认为 YES
  64. */
  65. @property (nonatomic, assign, readonly) BOOL useHttps;
  66. /**
  67. * 是否开启并发分片上传,默认为NO
  68. */
  69. @property (nonatomic, assign, readonly) BOOL useConcurrentResumeUpload;
  70. /**
  71. * 并发分片上传的并发任务个数,在concurrentResumeUpload为YES时有效,默认为3个
  72. */
  73. @property (nonatomic, assign, readonly) UInt32 concurrentTaskCount;
  74. @property (nonatomic, readonly) QNReportConfig *reportConfig;
  75. /**
  76. * 重试时是否允许使用备用上传域名,默认为YES
  77. */
  78. @property (nonatomic, assign) BOOL allowBackupHost;
  79. @property (nonatomic, readonly) id<QNRecorderDelegate> recorder;
  80. @property (nonatomic, readonly) QNRecorderKeyGenerator recorderKeyGen;
  81. @property (nonatomic, readonly) NSDictionary *proxy;
  82. @property (nonatomic, readonly) QNUrlConvert converter;
  83. + (instancetype)build:(QNConfigurationBuilderBlock)block;
  84. @end
  85. #define kQNGlobalConfiguration [QNGlobalConfiguration shared]
  86. @interface QNGlobalConfiguration : NSObject
  87. /**
  88. * 是否开启dns预解析 默认开启
  89. */
  90. @property(nonatomic, assign)BOOL isDnsOpen;
  91. /**
  92. * dns 预取失败后 会进行重新预取 rePreHostNum为最多尝试次数
  93. */
  94. @property(nonatomic, assign)UInt32 dnsRepreHostNum;
  95. /**
  96. * dns预取缓存时间 单位:秒
  97. */
  98. @property(nonatomic, assign)UInt32 dnsCacheTime;
  99. /**
  100. * 自定义DNS解析客户端host
  101. */
  102. @property(nonatomic, strong) id <QNDnsDelegate> dns;
  103. /**
  104. * dns解析结果本地缓存路径
  105. */
  106. @property(nonatomic, copy, readonly)NSString *dnscacheDir;
  107. + (instancetype)shared;
  108. @end
  109. @interface QNConfigurationBuilder : NSObject
  110. /**
  111. * 默认上传服务器地址
  112. */
  113. @property (nonatomic, strong) QNZone *zone;
  114. /**
  115. * 断点上传时的分片大小
  116. */
  117. @property (assign) UInt32 chunkSize;
  118. /**
  119. * 如果大于此值就使用断点上传,否则使用form上传
  120. */
  121. @property (assign) UInt32 putThreshold;
  122. /**
  123. * 上传失败时每个上传域名的重试次数,默认重试3次
  124. */
  125. @property (assign) UInt32 retryMax;
  126. /**
  127. * 重试前等待时长,默认0.5s
  128. */
  129. @property (assign) NSTimeInterval retryInterval;
  130. /**
  131. * 超时时间 单位 秒
  132. */
  133. @property (assign) UInt32 timeoutInterval;
  134. /**
  135. * 是否使用 https,默认为 YES
  136. */
  137. @property (nonatomic, assign) BOOL useHttps;
  138. /**
  139. * 重试时是否允许使用备用上传域名,默认为YES
  140. */
  141. @property (nonatomic, assign) BOOL allowBackupHost;
  142. /**
  143. * 是否开启并发分片上传,默认为NO
  144. */
  145. @property (nonatomic, assign) BOOL useConcurrentResumeUpload;
  146. /**
  147. * 并发分片上传的并发任务个数,在concurrentResumeUpload为YES时有效,默认为3个
  148. */
  149. @property (nonatomic, assign) UInt32 concurrentTaskCount;
  150. @property (nonatomic, strong) id<QNRecorderDelegate> recorder;
  151. @property (nonatomic, strong) QNRecorderKeyGenerator recorderKeyGen;
  152. @property (nonatomic, strong) QNReportConfig *reportConfig;
  153. @property (nonatomic, strong) NSDictionary *proxy;
  154. @property (nonatomic, strong) QNUrlConvert converter;
  155. @end