杨锴
2024-10-09 e987bc09f955e01c2835f01e3a6af20723a579f9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
//
//  OBSBaseConstDefinition.h
//  OBS
//
//  Created by MaxZhang on 10/10/2017.
//  Copyright © 2017 obs. All rights reserved.
//
 
#ifndef OBSBaseDefinition_h
#define OBSBaseDefinition_h
 
 
static NSString *const  OBSSDKVersion                           =@"3.24.4";
 
static NSUInteger const  maxConcurrentRequestCountDefault       =3;
 
static NSString *const  OBSURLReservedCharacters                =@"-_.~!*'();:=@&=+$,/?#[]%";
static NSString *const  OBSURLAllowedSpecialCharacters          =@"-_.";
 
static NSString *const  OBSAbstractClassPrefix                  =@"OBSAbstract";
#pragma mark - Errors messages;
static NSString *const  OBSClientErrorDomain                    =@"com.obs.clientError";
static NSString *const  OBSServerErrorDomain                    =@"com.obs.serverError";
static NSString *const  OBSErrorMessageTOKEN                    =@"ErrorMessage";
static NSString *const  OBSClientErrorHTTPRequestIDKey          =@"RequestID";
static NSString *const  OBSClientErrorHTTPCodeKey               =@"HTTPErrorCode";
static NSString *const  OBSClientErrorHTTPBodyKey               =@"HTTPErrorBody";
static NSString *const  OBSClientErrorInvalidParameter          =@"InvalidParameter";
 
static char     *const  OBSProcessorsQueueName                  ="com.obs.sdk.processors";
static NSString *const  OBSMaxConcurrentCommandRequestCountKey  =@"maxConcurrentCommandRequestCount";
static NSString *const  OBSMaxConcurrentUploadRequestCountKey   =@"maxConcurrentUploadRequestCount";
static NSString *const  OBSMaxConcurrentDownloadRequestCountKey =@"maxConcurrentDownloadRequestCount";
 
static NSString *const  OBSUploadBackgroundIdentifierDefault    =@"com.obs.sdk.upload";
static NSString *const  OBSDownloadBackgroundIdentifierDefault  =@"com.obs.sdk.download";
 
    //networking request definition dict keys;
    //common fields;
static NSString *const  OBSRequestTypeKey                       =@"requestType";
static NSString *const  OBSRequestIDKey                         =@"requestID";
static NSString *const  OBSRequestHTTPMethodKey                 =@"requestMethod";
static NSString *const  OBSRequestResourceStringKey             =@"requestResourceString";
static NSString *const  OBSRequestResourceParametersKey         =@"requestResourceParameters";
static NSString *const  OBSRequestQueryParametersKey            =@"requestQueryParameters";
static NSString *const  OBSRequestHeaderParametersKey           =@"requestHeadersParameters";
 
static NSString *const  OBSRequestBodyParameterKey              =@"requestBodyParameters";
static NSString *const  OBSRequestAddonRequestPostProcessorsKey =@"addonRequestPostProcessorsParameters";
static NSString *const  OBSRequestAddonResponsePreProcessorsKey =@"addonResponsePreProcessorsParameters";
static NSString *const  OBSRequestAuthRequiredKey               =@"authenticationRequired";
    //upload data fields;
static NSString *const  OBSRequestUploadDataKey                 =@"uploadData";
static NSString *const  OBSRequestUploadProgressBlockKey        =@"uploadProgressBlock";
    //download data fields;
static NSString *const  OBSRequestOnReceiveDataBlockKey         =@"onReceiveDataBlock";
static NSString *const  OBSRequestDownloadProgressBlockKey      =@"downloadProgressBlock";
    //upload and download fields;
static NSString *const  OBSRequestUploadFilePathKey             =@"uploadFilePath";
static NSString *const  OBSRequestDownloadFilePathKey           =@"downloadFilePath";
static NSString *const  OBSRequestBackgroundKey                 =@"background";
    // headesr key;
static NSString *const  OBSHeadersUAKey                         =@"User-Agent";
 
static NSString *const  OBSHeadersHostKey                       =@"Host";
static NSString *const  OBSHeadersContentTypeKey                =@"Content-Type";
static NSString *const  OBSHeadersContentLengthKey              =@"Content-Length";
static NSString *const  OBSHeadersAuthorizationKey              =@"Authorization";
static NSString *const  OBSDefaultContentType                   =@"binary/octet-stream";
    //date format;
static NSString *const  OBSDateShortFormat                      =@"yyyyMMdd";
static NSString *const  OBSDateRFC1123Format                    =@"E, dd MMM yyyy HH:mm:ss z";
static NSString *const  OBSDateISO8601Format1                   =@"yyyy-MM-dd'T'HH:mm:ss'Z'";
static NSString *const  OBSDateISO8601Format2                   =@"yyyyMMdd'T'HHmmss'Z'" ;
static NSString *const  OBSDateISO8601Format3                   =@"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
    //output keys and download temp file extention;
static NSString *const  OBSOutputCodeKey                        =@"statusCode";
static NSString *const  OBSOutputHeadersKey                     =@"headers";
static NSString *const  OBSOutputBodyKey                        =@"body";
 
 
static NSString *const OBSXMLDefaultNS                          =@" xmlns=\"http://s3.amazonaws.com/doc/2006-03-01/\"";
static NSString *const OBSXMLDefaultNS_OBS                          =@" xmlns=\"http://myhwclouds.com/doc/2015-06-30/\"";
 
static NSString *const OBSXMLDictionaryNodeOrderKey             =@"__order";
 
#pragma mark -Enum
/**
 *  OBS鉴权版本枚举
 */
 
typedef NS_ENUM(NSInteger, OBSContentType) {
    /**
     *  默认类型
     */
    OBSContentTypeNULL0,
    /**
     *  mp4
     */
    OBSContentTypeMP4,
    /**
     *  二进制流
     */
    OBSContentTypeBinary,
    /**
     *  JPEG
     */
    OBSContentTypeJPEG,
    /**
     *  PNG
     */
    OBSContentTypePNG,
    /**
     *  HTML
     */
    OBSContentTypeHTML,
    /**
     *  GIF
     */
    OBSContentTypeGIF,
    /**
     *  PDF
     */
    OBSContentTypePDF,
    /**
     *  MP3
     */
    OBSContentTypeMP3,
    /**
     *  WAV
     */
    OBSContentTypeWAV,
    /**
     *  MOV
     */
    OBSContentTypeMOV,
    /**
     *  m3u8
     */
    OBSContentTypeM3U8,
};
 
typedef NS_ENUM(NSInteger, OBSAuthVersion) {
    /**
     *  默认鉴权
     */
    OBSAuthVersionNULL0,
    /**
     *  V2鉴权
     */
    OBSAuthVersionV2,
    /**
     *  V4鉴权
     */
    OBSAuthVersionV4,
};
 
/**
 *  OBS协议种类
 */
typedef NS_ENUM(NSInteger, OBSProtocolType) {
   
    /**
     *  旧版本协议
     */
    OBSProtocolTypeOld,
    /**
     *  自研协议
     */
    OBSProtocolTypeOBS,
};
 
/**
 *  OBS错误码枚举
 */
typedef NS_ENUM(NSInteger, OBSErrorCode) {
    /**
     *  默认
     */
    OBSErrorCodeNoErrorCode0,
    /**
     *  服务器错误
     */
    OBSErrorCodeServerErrorStatus,
    /**
     *  客户端错误
     */
    OBSErrorCodeClientErrorStatus,
};
 
/**
 *  OBS客户端错误码枚举
 */
typedef NS_ENUM(NSInteger, OBSClientErrorCODE) {
    /**
     *  默认
     */
    OBSRequestNoErrorCode0,
    /**
     *  定义未找到
     */
    OBSClientErrorRequestDefinitionNotFoundCode,
    /**
     *   响应错误码
     */
    OBSClientErrorHTTPResponseCodeError,
    /**
     *  签名错误
     */
    OBSClientErrorCodeSignFailed,
//    OBSClientErrorCodeNetworkingFailWithResponseCode0,
//    OBSClientErrorCodeFileCantWrite,
//    OBSClientErrorCodeInvalidArgument,
//    OBSClientErrorCodeNilUploadid,
//    OBSClientErrorCodeTaskCancelled,
//    OBSClientErrorCodeNetworkError,
//    OBSClientErrorCodeCannotResumeUpload,
//    OBSClientErrorCodeExcpetionCatched,
//    OBSClientErrorCodeNotKnown
};
 
/**
 *  OBS请求代理类型
 */
typedef NS_ENUM(NSInteger, OBSHTTPProxyType) {
    /**
     *  默认
     */
    OBSHTTPRroxyTypeNull0,
    /**
     *  HTTP
     */
    OBSHTTPRroxyTypeHTTP,
    /**
     *  HTTPS
     */
    OBSHTTPRroxyTypeHTTPS,
    /**
     *  HTTP & HTTPS
     */
    OBSHTTPRroxyTypeHTTPAndHTTPS,
};
 
/**
 *  请求类型
 */
typedef NS_ENUM(NSInteger, OBSRequestType){
    /**
     *  默认
     */
    OBSRequestTypeNull0,
    /**
     *  命令
     */
    OBSRequestTypeCommandRequest,
    /**
     *  上传数据
     */
    OBSRequestTypeUploadDataRequest,
    /**
     *  上传文件
     */
    OBSRequestTypeUploadFileRequest,
    /**
     *  下载数据
     */
    OBSRequestTypeDownloadDataRequest,
    /**
     *  下载文件
     */
    OBSRequestTypeDownloadFileRequest,
};
 
/**
 *  请求体内容
 */
typedef NS_ENUM(NSInteger, OBSBodyType){
    /**
     *  默认
     */
    OBSBodyTypeNull0,
    /**
     *  JSON
     */
    OBSBodyTypeJSON,
    /**
     *  XML
     */
    OBSBodyTypeXML,
    /**
     *  字符串
     */
    OBSBodyTypeStringData,
};
/**
 *  请求方法类型枚举
 */
typedef NS_ENUM(NSInteger, OBSHTTPMethod){
    OBSHTTPMethodNull0,
    OBSHTTPMethodGET,
    OBSHTTPMethodHEAD,
    OBSHTTPMethodPUT,
    OBSHTTPMethodPOST,
    OBSHTTPMethodTRACE,
    OBSHTTPMethodOPTIONS,
    OBSHTTPMethodDELETE,
    OBSHTTPMethodLOCK,
    OBSHTTPMethodMKCOL,
    OBSHTTPMethodMOVE,
};
 
 
#pragma mark - ignore warn
#define SuppressPerformSelectorLeakWarning(code) \
        _Pragma("clang diagnostic push") \
        _Pragma("clang diagnostic ignored \"-Warc-performSelector-leaks\"") \
        code\
        _Pragma("clang diagnostic pop") \
 
#define SuppressMethodDefinitionNotFoundWarning(code) \
        _Pragma("clang diagnostic push") \
        _Pragma("clang diagnostic ignored \"-Wincomplete-implementation\"") \
        code\
        _Pragma("clang diagnostic pop") \
 
#define MakeDispatchOnceDictBEGIN \
        static NSDictionary *dict; \
        static dispatch_once_t onceToken; \
        dispatch_once(&onceToken, ^{
 
#define MakeDispatchOnceDictEND\
        });  \
 
 
#define MakeDispatchOnceArrayBEGIN \
        static NSArray *array; \
        static dispatch_once_t onceToken; \
        dispatch_once(&onceToken, ^{
 
#define MakeDispatchOnceArrayEND\
        });  \
 
#define MakeDispatchOnceTransformerBEGIN \
static NSValueTransformer *transformer; \
static dispatch_once_t onceToken; \
dispatch_once(&onceToken, ^{
 
#define MakeDispatchOnceTransformerEND \
});  \
 
 
#define metamacro_concat(A,B) A ## B
#define weakify(VAR) \
autoreleasepool {} \
__weak __typeof__(VAR) weak##VAR = VAR
    //    __weak __typeof__(VAR) metamacro_concat(VAR, _weak_) = (VAR)
 
#define strongify(VAR) \
autoreleasepool {} \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wshadow\"") \
__strong __typeof__(VAR) VAR = metamacro_concat(VAR, _weak_)\
_Pragma("clang diagnostic pop") \
 
#pragma mark - Progress block
typedef void (^OBSNetworkingUploadProgressBlock) (int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend);
typedef void (^OBSNetworkingDownloadProgressBlock) (int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite);
typedef void (^OBSNetworkingOnReceiveDataBlock)(NSData *data);
#endif /* OBSConstDefinition_h */