commit | author | age
|
a0a843
|
1 |
// |
H |
2 |
// TWTRMultipartFormDocument.h |
|
3 |
// TwitterCore |
|
4 |
// |
|
5 |
// Created by Chase Latta on 8/19/15. |
|
6 |
// Copyright (c) 2015 Twitter Inc. All rights reserved. |
|
7 |
// |
|
8 |
|
|
9 |
#import <Foundation/Foundation.h> |
|
10 |
|
|
11 |
NS_ASSUME_NONNULL_BEGIN |
|
12 |
|
|
13 |
typedef void (^TWTRMultipartFormDocumentLoadDataCallback)(NSData *data); |
|
14 |
|
|
15 |
@interface TWTRMultipartFormElement : NSObject |
|
16 |
|
|
17 |
/** |
|
18 |
* The name of the form element. |
|
19 |
*/ |
|
20 |
@property (nonatomic, copy, readonly) NSString *name; |
|
21 |
|
|
22 |
/** |
|
23 |
* The content type of the form element. |
|
24 |
*/ |
|
25 |
@property (nonatomic, copy, readonly) NSString *contentType; |
|
26 |
|
|
27 |
/** |
|
28 |
* An optional filename for this element. |
|
29 |
*/ |
|
30 |
@property (nonatomic, copy, readonly, nullable) NSString *fileName; |
|
31 |
|
|
32 |
/** |
|
33 |
* The content's data. |
|
34 |
*/ |
|
35 |
@property (nonatomic, copy, readonly) NSData *content; |
|
36 |
|
|
37 |
/** |
|
38 |
* Returns a fully initialized form element to be used in a multipart for document. |
|
39 |
* |
|
40 |
* @param name the name of the element |
|
41 |
* @param contentType the elements content type |
|
42 |
* @param fileName an optional file name |
|
43 |
* @param content the data associated with this item |
|
44 |
*/ |
|
45 |
- (instancetype)initWithName:(NSString *)name contentType:(NSString *)contentType fileName:(nullable NSString *)fileName content:(NSData *)content NS_DESIGNATED_INITIALIZER; |
|
46 |
|
|
47 |
- (instancetype)init NS_UNAVAILABLE; |
|
48 |
|
|
49 |
@end |
|
50 |
|
|
51 |
/** |
|
52 |
* A class representing a multipart form document. |
|
53 |
*/ |
|
54 |
@interface TWTRMultipartFormDocument : NSObject |
|
55 |
|
|
56 |
/** |
|
57 |
* The forms boundary |
|
58 |
*/ |
|
59 |
@property (nonatomic, copy, readonly) NSString *boundary; |
|
60 |
|
|
61 |
/** |
|
62 |
* Returns a value appropriate for the Content-Type header field |
|
63 |
*/ |
|
64 |
@property (nonatomic, copy, readonly) NSString *contentTypeHeaderField; |
|
65 |
|
|
66 |
/** |
|
67 |
* Instantiates the document with the given elements. |
|
68 |
* |
|
69 |
* @param formElements the elements to append to this document |
|
70 |
*/ |
|
71 |
- (instancetype)initWithFormElements:(NSArray *)formElements NS_DESIGNATED_INITIALIZER; |
|
72 |
|
|
73 |
/** |
|
74 |
* Asynchrounously loads the body data. |
|
75 |
* |
|
76 |
* @param callbackQueue the queue to invoke the handler on |
|
77 |
* @param completion the completion block to call with the loaded data. |
|
78 |
*/ |
|
79 |
- (void)loadBodyDataWithCallbackQueue:(dispatch_queue_t)callbackQueue completion:(TWTRMultipartFormDocumentLoadDataCallback)completion; |
|
80 |
|
|
81 |
@end |
|
82 |
|
|
83 |
NS_ASSUME_NONNULL_END |