洛阳学员端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

292 lines
7.3 KiB

7 months ago
  1. //
  2. // OSSModel.h
  3. // oss_ios_sdk
  4. //
  5. // Created by zhouzhuo on 8/16/15.
  6. // Copyright (c) 2015 aliyun.com. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import "OSSRequest.h"
  10. #import "OSSResult.h"
  11. @class OSSAllRequestNeededMessage;
  12. @class OSSFederationToken;
  13. @class OSSTask;
  14. @class OSSClientConfiguration;
  15. NS_ASSUME_NONNULL_BEGIN
  16. typedef OSSFederationToken * _Nullable (^OSSGetFederationTokenBlock) (void);
  17. /**
  18. Categories NSDictionary
  19. */
  20. @interface NSDictionary (OSS)
  21. - (NSString *)base64JsonString;
  22. @end
  23. /**
  24. A thread-safe dictionary
  25. */
  26. @interface OSSSyncMutableDictionary : NSObject
  27. @property (nonatomic, strong) NSMutableDictionary *dictionary;
  28. @property (nonatomic, strong) dispatch_queue_t dispatchQueue;
  29. - (id)objectForKey:(id)aKey;
  30. - (NSArray *)allKeys;
  31. - (void)setObject:(id)anObject forKey:(id <NSCopying>)aKey;
  32. - (void)removeObjectForKey:(id)aKey;
  33. @end
  34. /**
  35. FederationToken class
  36. */
  37. @interface OSSFederationToken : NSObject
  38. @property (nonatomic, copy) NSString * tAccessKey;
  39. @property (nonatomic, copy) NSString * tSecretKey;
  40. @property (nonatomic, copy) NSString * tToken;
  41. /**
  42. Token's expiration time in milliseconds of the unix time.
  43. */
  44. @property (atomic, assign) int64_t expirationTimeInMilliSecond;
  45. /**
  46. Token's expiration time in GMT format string.
  47. */
  48. @property (atomic, strong, nullable) NSString *expirationTimeInGMTFormat;
  49. @end
  50. /**
  51. CredentialProvider protocol, needs to implement sign API.
  52. */
  53. @protocol OSSCredentialProvider <NSObject>
  54. @optional
  55. - (nullable NSString *)sign:(NSString *)content error:(NSError **)error;
  56. @end
  57. /**
  58. The STS token's credential provider.
  59. */
  60. @interface OSSStsTokenCredentialProvider : NSObject <OSSCredentialProvider>
  61. @property (nonatomic, copy) NSString * accessKeyId;
  62. @property (nonatomic, copy) NSString * secretKeyId;
  63. @property (nonatomic, copy) NSString * securityToken;
  64. - (OSSFederationToken *)getToken;
  65. - (instancetype)initWithAccessKeyId:(NSString *)accessKeyId
  66. secretKeyId:(NSString *)secretKeyId
  67. securityToken:(NSString *)securityToken;
  68. @end
  69. /**
  70. OSSClient side configuration.
  71. */
  72. @interface OSSClientConfiguration : NSObject
  73. /**
  74. Max retry count
  75. */
  76. @property (nonatomic, assign) uint32_t maxRetryCount;
  77. /**
  78. Max concurrent requests
  79. */
  80. @property (nonatomic, assign) uint32_t maxConcurrentRequestCount;
  81. /**
  82. Flag of enabling background file transmit service.
  83. Note: it's only applicable for file upload.
  84. */
  85. @property (nonatomic, assign) BOOL enableBackgroundTransmitService;
  86. /**
  87. Sets the session Id for background file transmission
  88. */
  89. @property (nonatomic, copy) NSString * backgroundSesseionIdentifier;
  90. /**
  91. Sets request timeout
  92. */
  93. @property (nonatomic, assign) NSTimeInterval timeoutIntervalForRequest;
  94. /**
  95. Sets single object download's max time
  96. */
  97. @property (nonatomic, assign) NSTimeInterval timeoutIntervalForResource;
  98. /**
  99. Sets proxy host and port.
  100. */
  101. @property (nonatomic, copy) NSString * proxyHost;
  102. @property (nonatomic, strong) NSNumber * proxyPort;
  103. /**
  104. Sets UA
  105. */
  106. @property (nonatomic, copy) NSString * userAgentMark;
  107. /**
  108. Sets the flag of using Second Level Domain style to access the endpoint. By default it's false.
  109. */
  110. @property (nonatomic, assign) BOOL isPathStyleAccessEnable;
  111. /**
  112. Sets the flag of using custom path prefix to access the endpoint. By default it's false.
  113. */
  114. @property (nonatomic, assign) BOOL isCustomPathPrefixEnable;
  115. /**
  116. Sets CName excluded list.
  117. */
  118. @property (nonatomic, strong, setter=setCnameExcludeList:) NSArray * cnameExcludeList;
  119. /**
  120. crc校验(checkCRC开关时checkCRC开关为准)
  121. */
  122. @property (nonatomic, assign) BOOL crc64Verifiable;
  123. @end
  124. @protocol OSSRequestInterceptor <NSObject>
  125. - (OSSTask *)interceptRequestMessage:(OSSAllRequestNeededMessage *)request;
  126. @end
  127. /**
  128. Signs the request when it's being created.
  129. */
  130. @interface OSSSignerInterceptor : NSObject <OSSRequestInterceptor>
  131. @property (nonatomic, strong) id<OSSCredentialProvider> credentialProvider;
  132. - (instancetype)initWithCredentialProvider:(id<OSSCredentialProvider>)credentialProvider;
  133. @end
  134. /**
  135. Updates the UA when creating the request.
  136. */
  137. @interface OSSUASettingInterceptor : NSObject <OSSRequestInterceptor>
  138. @property (nonatomic, weak) OSSClientConfiguration *clientConfiguration;
  139. - (instancetype)initWithClientConfiguration:(OSSClientConfiguration *) clientConfiguration;
  140. @end
  141. /**
  142. Fixes the time skew issue when creating the request.
  143. */
  144. @interface OSSTimeSkewedFixingInterceptor : NSObject <OSSRequestInterceptor>
  145. @end
  146. #pragma mark RequestAndResultClass
  147. @interface OSSPutObjectRequest : OSSRequest
  148. /**
  149. Bucket name
  150. */
  151. @property (nonatomic, copy) NSString * bucketName;
  152. /**
  153. Object name
  154. */
  155. @property (nonatomic, copy) NSString * objectKey;
  156. /**
  157. The in-memory data to upload.
  158. */
  159. @property (nonatomic, strong) NSData * uploadingData;
  160. /**
  161. The local file path to upload.
  162. */
  163. @property (nonatomic, strong) NSURL * uploadingFileURL;
  164. /**
  165. The callback parameters.
  166. */
  167. @property (nonatomic, copy) NSDictionary * callbackParam;
  168. /**
  169. The callback variables.
  170. */
  171. @property (nonatomic, copy) NSDictionary * callbackVar;
  172. /**
  173. The content type.
  174. */
  175. @property (nonatomic, copy) NSString * contentType;
  176. /**
  177. The content's MD5 digest.
  178. It's calculated on the request body (not headers) according to RFC 1864 to get the 128 bit digest data.
  179. Then use base64 encoding on the 128bit result to get this MD5 value.
  180. This header is for integrity check on the data. And it's recommended to turn on for every body.
  181. */
  182. @property (nonatomic, copy) NSString * contentMd5;
  183. /**
  184. Specifies the download name of the object. Checks out RFC2616 for more details.
  185. */
  186. @property (nonatomic, copy) NSString * contentDisposition;
  187. /**
  188. Specifies the content encoding during the download. Checks out RFC2616 for more details.
  189. */
  190. @property (nonatomic, copy) NSString * contentEncoding;
  191. /**
  192. Specifies the cache behavior during the download. Checks out RFC2616 for more details.
  193. */
  194. @property (nonatomic, copy) NSString * cacheControl;
  195. /**
  196. Expiration time in milliseconds. Checks out RFC2616 for more details.
  197. */
  198. @property (nonatomic, copy) NSString * expires;
  199. /**
  200. The object's metadata.
  201. When the object is being uploaded, it could be specified with http headers prefixed with x-oss-meta for user metadata.
  202. The total size of all user metadata cannot be more than 8K.
  203. It also could include standard HTTP headers in this object.
  204. */
  205. @property (nonatomic, copy) NSDictionary * objectMeta;
  206. /**
  207. The upload progress callback.
  208. It runs in background thread (not UI thread).
  209. */
  210. @property (nonatomic, copy) OSSNetworkingUploadProgressBlock uploadProgress;
  211. /**
  212. The upload retry callback.
  213. It runs in background thread (not UI thread).
  214. */
  215. @property (nonatomic, copy) OSSNetworkingRetryBlock uploadRetryCallback;
  216. /**
  217. * the sha1 of content
  218. */
  219. @property (nonatomic, copy) NSString *contentSHA1;
  220. @end
  221. /**
  222. The result class to put an object
  223. */
  224. @interface OSSPutObjectResult : OSSResult
  225. /**
  226. ETag (entity tag) is the tag during the object creation in OSS server side.
  227. It's the MD5 value for put object request. If the object is created by other APIs, the ETag is the UUID of the content.
  228. ETag could be used to check if the object has been updated.
  229. */
  230. @property (nonatomic, copy) NSString * eTag;
  231. /**
  232. If the callback is specified, this is the callback response result.
  233. */
  234. @property (nonatomic, copy) NSString * serverReturnJsonString;
  235. @end
  236. NS_ASSUME_NONNULL_END