9
9
10
10
@interface RNUploader : NSObject <RCTBridgeModule, NSURLConnectionDelegate , NSURLConnectionDataDelegate >
11
11
@property NSMutableData *responseData;
12
+ @property NSInteger responseStatusCode;
13
+
12
14
@property NSMutableURLRequest *request;
13
15
@property NSMutableData *requestBody;
14
16
@property NSMutableArray *files;
@@ -19,8 +21,6 @@ @interface RNUploader : NSObject <RCTBridgeModule, NSURLConnectionDelegate, NSUR
19
21
@property dispatch_group_t fgroup;
20
22
@end
21
23
22
-
23
-
24
24
@implementation RNUploader
25
25
26
26
@synthesize bridge = _bridge;
@@ -59,7 +59,6 @@ @implementation RNUploader
59
59
});
60
60
}
61
61
62
-
63
62
//
64
63
// Action Methods
65
64
//
@@ -183,7 +182,6 @@ - (void)sendRequest {
183
182
[connection start ];
184
183
}
185
184
186
-
187
185
//
188
186
// Helpers
189
187
//
@@ -208,7 +206,6 @@ - (NSString *)mimeTypeForPath:(NSString *)filepath
208
206
return contentType;
209
207
}
210
208
211
-
212
209
//
213
210
// Delegate Methods
214
211
//
@@ -224,7 +221,7 @@ - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)err
224
221
225
222
- (void )connection : (NSURLConnection *)connection didReceiveResponse : (NSURLResponse *)response {
226
223
[self .bridge.eventDispatcher sendDeviceEventWithName: @" RNUploaderDidReceiveResponse" body: nil ];
227
-
224
+ self. responseStatusCode = [( NSHTTPURLResponse *)response statusCode ];
228
225
}
229
226
230
227
- (void )connection : (NSURLConnection *)connection didReceiveData : (NSData *)data {
@@ -236,8 +233,10 @@ - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
236
233
- (void )connectionDidFinishLoading : (NSURLConnection *)connection {
237
234
NSString *responseString = [[NSString alloc ] initWithData: self .responseData encoding: NSUTF8StringEncoding];
238
235
[self .bridge.eventDispatcher sendDeviceEventWithName: @" RNUploaderDataFinishLoading" body: responseString];
239
- _callback (@[[NSNull null ], responseString]);
240
-
236
+
237
+ NSDictionary *res= [[NSDictionary alloc ] initWithObjectsAndKeys: [NSNumber numberWithInteger: self .responseStatusCode],@" status" ,responseString,@" data" ,nil ];
238
+
239
+ _callback (@[[NSNull null ], res]);
241
240
}
242
241
243
242
- (void )connection : (NSURLConnection *)connection didSendBodyData : (NSInteger )bytesWritten totalBytesWritten : (NSInteger )totalBytesWritten totalBytesExpectedToWrite : (NSInteger )totalBytesExpectedToWrite {
0 commit comments