杨锴
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
//
//  OBSPutObjectRequest.h
//  OBS
//
//  Created by MaxZhang on 07/11/2017.
//  Copyright © 2017 obs. All rights reserved.
//
 
#ifndef OBSPutObjectRequest_h
#define OBSPutObjectRequest_h
 
#import "OBSBaseNetworking.h"
#import "OBSClient.h"
#import "OBSServiceBaseModel.h"
#import "OBSServiceConstDefinition.h"
 
    //request
@class OBSAbstractEncryption;
#pragma mark - request
 
/**
 上传对象
 */
@protocol OBSPutObjectProtocol<NSObject>
@required
 
/**
 桶名
 */
@property (nonatomic, strong, nonnull) NSString *bucketName;
 
/**
 对象名
 */
@property (nonatomic, strong, nonnull) NSString *objectKey;
 
/**
 MD5值
 */
@property (nonatomic, strong, nonnull) NSString *contentMD5;
 
/**
 对象访问策略
 */
@property (nonatomic, assign) OBSACLPolicy objectACLPolicy;
 
/**
 对象存储类型
 */
@property (nonatomic, assign) OBSStorageClass storageClass;
 
/**
 元数据字典
 */
@property (nonatomic, strong, nullable) NSDictionary *metaDataDict;
 
/**
 重定向地址
 */
@property (nonatomic, strong, nonnull) NSString *websiteRedirectLocation;
 
/**
 加密方式
 */
@property (nonatomic, strong, nonnull) __kindof OBSAbstractEncryption *encryption;
 
/**
 上传进度
 */
@property (nonatomic, copy, nonnull) OBSNetworkingUploadProgressBlock uploadProgressBlock;
/**
 MIME类型
 */
@property (nonatomic, assign) OBSContentType contentType;
@end
 
 
/**
 上传对象request父类
 */
@interface OBSAbstractPutObjectRequest : OBSBaseRequest<OBSPutObjectProtocol>
 
/**
 桶名
 */
@property (nonatomic, strong, nonnull) NSString *bucketName;
 
/**
 对象描述标识
 */
@property (nonatomic, strong, nonnull) NSString *objectKey;
 
/**
 对象的MD5
 */
@property (nonatomic, strong, nonnull) NSString *contentMD5;
 
/**
 对象的ACL
 */
@property (nonatomic, assign) OBSACLPolicy objectACLPolicy;
 
/**
 对象存储类型
 */
@property (nonatomic, assign) OBSStorageClass storageClass;
 
/**
 对象元数据字典
 */
@property (nonatomic, strong, nullable) NSDictionary *metaDataDict;
 
/**
 对象重定向地址
 */
@property (nonatomic, strong, nonnull) NSString *websiteRedirectLocation;
 
/**
 创建对象时,使用此头域授权domain下所有用户有读对象和获取对象元数据的权限
 */
@property (nonatomic, strong, nonnull) NSString *granteRead;
 
/**
创建对象时,使用此头域授权domain下所有用户有读对象和获取对象元数据的权限
*/
@property (nonatomic, strong, nonnull) NSString *granteReadAcp;
 
/**
 创建对象时,使用此头域授权domain下所有用户有获取对象ACL的权限
 */
@property (nonatomic, strong, nonnull) NSString *granteWriteAcp;
 
/**
 创建对象时,使用此头域授权domain下所有用户有读对象、获取对象元数据、获取对象ACL、写对象ACL的权限
 */
@property (nonatomic, strong, nonnull) NSString *granteFullControl;
 
/**
 此参数的值是一个URL,用于指定当此次请求操作成功响应后的重定向的地址
 如果此参数值有效且操作成功,响应码为303,location头域由此参数以及桶名、对象名、对象的ETag组成
 如果此参数值无效,忽略此参数的作用,响应码为204,location头域为对象地址
 */
@property (nonatomic, strong, nonnull) NSString *actionRedirect;
 
/**
 表示上传对象的过期时间,单位是天
 */
@property (nonatomic, strong, nonnull) NSNumber *expires;
 
/**
 MIME类型
 */
@property (nonatomic, assign) OBSContentType contentType;
 
/**
 自定义MIME类型
 */
@property (nonatomic, strong, nonnull) NSString *customContentType;
 
/**
 最终映射MIME类型
 */
@property (nonatomic, strong, nonnull) NSString *finalContentType;
 
/**
 加密方式
 */
@property (nonatomic, strong, nonnull) __kindof OBSAbstractEncryption *encryption;
 
/**
 上传对象时的回调
 */
@property (nonatomic, copy, nonnull) OBSNetworkingUploadProgressBlock uploadProgressBlock;
@end
 
 
/**
 流式上传对象request
 */
@interface OBSPutObjectWithDataRequest: OBSAbstractPutObjectRequest
 
/**
 上传的数据
 */
@property (nonatomic, strong, nonnull) NSData *uploadData;
 
/**
 初始化流式上传对象request
 
 @param bucketName 桶名
 @param objectKey 对象名
 @param data 需要上传的对象数据
 @return 流式上传对象request
 */
-(instancetype)initWithBucketName:(NSString*) bucketName objectKey: (NSString*) objectKey uploadData:(NSData*) data;
 
/**
 初始上传网络流对象request
 
 @param bucketName 桶名
 @param objectKey 对象名
 @param dataURL 需要上传的网络流地址
 @return 上传网络流对象request
 */
-(instancetype)initWithBucketName:(NSString*) bucketName objectKey: (NSString*) objectKey uploadDataURL:(NSURL*) dataURL;
@end
 
/**
 通过文件上传对象request
 */
@interface OBSPutObjectWithFileRequest: OBSAbstractPutObjectRequest
 
/**
 文件路径
 */
@property (nonatomic, strong, nonnull) NSString *uploadFilePath;
@property (nonatomic, assign) BOOL background;
 
/**
 初始化通过文件上传对象request
 
 @param bucketName 桶名
 @param objectKey 对象描述标识
 @param uploadFilePath 文件路径
 @return 通过文件上传对象request
 */
-(instancetype)initWithBucketName:(NSString*) bucketName objectKey: (NSString*) objectKey uploadFilePath:(NSString*) uploadFilePath;
@end
 
#pragma mark - networking request
@interface OBSNetworkingPutObjectWithDataRequest : OBSServiceNetworkingUploadDataRequest
@end
@interface OBSNetworkingPutObjectWithFileRequest : OBSServiceNetworkingUploadFileRequest
@end
 
    //response
#pragma mark - response
 
/**
 上传对象响应
 */
@interface OBSPutObjectResponse: OBSServiceResponse
 
/**
 对象etag值
 */
@property (nonatomic, strong, nonnull) NSString *etag;
 
/**
 如果桶开启了多版本状态 则返回版本号
 */
@property (nonatomic, strong, nonnull) NSString *versionID;
 
/**
 对象存储类型
 */
@property (nonatomic, assign) OBSStorageClass storageClass;
 
/**
 对象加密方式
 */
@property (nonatomic, strong, nonnull) __kindof OBSAbstractEncryption *encryption;
@end
 
    //client method
#pragma mark - client method
@interface OBSClient(putObject)
 
/**
 上传对象
 
 @param request 上传对象request
 @param completionHandler 上传对象回调
 @return OBSBFTask
 */
- (OBSBFTask*)putObject:(__kindof OBSBaseRequest<OBSPutObjectProtocol>*)request
              completionHandler:(void (^)(OBSPutObjectResponse  * response, NSError * error))completionHandler;
@end
#endif  /* OBSPutObjectRequest_h */