Skip to content
This repository was archived by the owner on Mar 16, 2019. It is now read-only.

Commit 7d42a75

Browse files
committed
refactor IOS native code
1 parent b636868 commit 7d42a75

File tree

9 files changed

+773
-647
lines changed

9 files changed

+773
-647
lines changed

src/ios/RNFetchBlob.xcodeproj/project.pbxproj

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
A158F4271D052E49006FFD38 /* RNFetchBlobFS.m in Sources */ = {isa = PBXBuildFile; fileRef = A158F4261D052E49006FFD38 /* RNFetchBlobFS.m */; };
11+
A158F42D1D0535BB006FFD38 /* RNFetchBlobConst.m in Sources */ = {isa = PBXBuildFile; fileRef = A158F42C1D0535BB006FFD38 /* RNFetchBlobConst.m */; };
12+
A158F4301D0539DB006FFD38 /* RNFetchBlobResp.m in Sources */ = {isa = PBXBuildFile; fileRef = A158F42F1D0539DB006FFD38 /* RNFetchBlobResp.m */; };
1013
A15C30141CD25C330074CB35 /* RNFetchBlob.m in Sources */ = {isa = PBXBuildFile; fileRef = A15C30131CD25C330074CB35 /* RNFetchBlob.m */; };
1114
A166D1AA1CE0647A00273590 /* RNFetchBlob.h in Sources */ = {isa = PBXBuildFile; fileRef = A15C30111CD25C330074CB35 /* RNFetchBlob.h */; };
1215
/* End PBXBuildFile section */
@@ -24,6 +27,12 @@
2427
/* End PBXCopyFilesBuildPhase section */
2528

2629
/* Begin PBXFileReference section */
30+
A158F4261D052E49006FFD38 /* RNFetchBlobFS.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNFetchBlobFS.m; sourceTree = "<group>"; };
31+
A158F4281D052E57006FFD38 /* RNFetchBlobFS.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNFetchBlobFS.h; sourceTree = "<group>"; };
32+
A158F4291D0534A9006FFD38 /* RNFetchBlobConst.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNFetchBlobConst.h; sourceTree = "<group>"; };
33+
A158F42C1D0535BB006FFD38 /* RNFetchBlobConst.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNFetchBlobConst.m; sourceTree = "<group>"; };
34+
A158F42E1D0539CE006FFD38 /* RNFetchBlobResp.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNFetchBlobResp.h; sourceTree = "<group>"; };
35+
A158F42F1D0539DB006FFD38 /* RNFetchBlobResp.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNFetchBlobResp.m; sourceTree = "<group>"; };
2736
A15C300E1CD25C330074CB35 /* libRNFetchBlob.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNFetchBlob.a; sourceTree = BUILT_PRODUCTS_DIR; };
2837
A15C30111CD25C330074CB35 /* RNFetchBlob.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = RNFetchBlob.h; path = RNFetchBlob/RNFetchBlob.h; sourceTree = "<group>"; };
2938
A15C30131CD25C330074CB35 /* RNFetchBlob.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = RNFetchBlob.m; path = RNFetchBlob/RNFetchBlob.m; sourceTree = "<group>"; };
@@ -50,6 +59,12 @@
5059
A15C30051CD25C330074CB35 = {
5160
isa = PBXGroup;
5261
children = (
62+
A158F42F1D0539DB006FFD38 /* RNFetchBlobResp.m */,
63+
A158F42E1D0539CE006FFD38 /* RNFetchBlobResp.h */,
64+
A158F42C1D0535BB006FFD38 /* RNFetchBlobConst.m */,
65+
A158F4291D0534A9006FFD38 /* RNFetchBlobConst.h */,
66+
A158F4281D052E57006FFD38 /* RNFetchBlobFS.h */,
67+
A158F4261D052E49006FFD38 /* RNFetchBlobFS.m */,
5368
A15C30111CD25C330074CB35 /* RNFetchBlob.h */,
5469
A15C30131CD25C330074CB35 /* RNFetchBlob.m */,
5570
A15C300F1CD25C330074CB35 /* Products */,
@@ -122,6 +137,9 @@
122137
buildActionMask = 2147483647;
123138
files = (
124139
A166D1AA1CE0647A00273590 /* RNFetchBlob.h in Sources */,
140+
A158F42D1D0535BB006FFD38 /* RNFetchBlobConst.m in Sources */,
141+
A158F4271D052E49006FFD38 /* RNFetchBlobFS.m in Sources */,
142+
A158F4301D0539DB006FFD38 /* RNFetchBlobResp.m in Sources */,
125143
A15C30141CD25C330074CB35 /* RNFetchBlob.m in Sources */,
126144
);
127145
runOnlyForDeploymentPostprocessing = 0;

src/ios/RNFetchBlob/RNFetchBlob.h

Lines changed: 0 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -6,96 +6,8 @@
66

77
#ifndef RNFetchBlob_h
88
#define RNFetchBlob_h
9-
#import <Foundation/Foundation.h>
109
#import "RCTBridgeModule.h"
1110

12-
// lib event
13-
extern NSString *const MSG_EVENT;
14-
extern NSString *const MSG_EVENT_LOG;
15-
extern NSString *const MSG_EVENT_WARN;
16-
extern NSString *const MSG_EVENT_ERROR;
17-
extern NSString *const FILE_PREFIX;
18-
19-
// config
20-
extern NSString *const CONFIG_USE_TEMP;
21-
extern NSString *const CONFIG_FILE_PATH;
22-
extern NSString *const CONFIG_FILE_EXT;
23-
24-
// fs events
25-
extern NSString *const FS_EVENT_DATA;
26-
extern NSString *const FS_EVENT_END;
27-
extern NSString *const FS_EVENT_WARN;
28-
extern NSString *const FS_EVENT_ERROR;
29-
30-
@interface FetchBlobFS : NSObject <NSStreamDelegate> {
31-
NSOutputStream * outStream;
32-
NSInputStream * inStream;
33-
RCTResponseSenderBlock callback;
34-
RCTBridge * bridge;
35-
Boolean isOpen;
36-
NSString * encoding;
37-
int bufferSize;
38-
BOOL appendData;
39-
NSString * taskId;
40-
NSString * path;
41-
NSString * streamId;
42-
}
43-
44-
@property (nonatomic) NSOutputStream * outStream;
45-
@property (nonatomic) NSInputStream * inStream;
46-
@property (nonatomic) RCTResponseSenderBlock callback;
47-
@property (nonatomic) RCTBridge * bridge;
48-
@property (nonatomic) NSString * encoding;
49-
@property (nonatomic) NSString * taskId;
50-
@property (nonatomic) NSString * path;
51-
@property (nonatomic) int bufferSize;
52-
@property (nonatomic) NSString * streamId;
53-
@property (nonatomic) BOOL appendData;
54-
55-
+ (NSString *) getTempPath;
56-
+ (FetchBlobFS *) getFileStreams;
57-
- (id) init;
58-
- (void) initWithCallback;
59-
- (void) initWithBridgeRef;
60-
- (void) openWithDestination;
61-
- (void) openWithId;
62-
- (NSString *) openWithPath;
63-
- (void) write;
64-
- (void) read;
65-
- (void) closeInStream;
66-
- (void) closeOutStream;
67-
68-
@end
69-
70-
@interface FetchBlobUtils : NSObject <NSURLConnectionDelegate, NSURLConnectionDataDelegate> {
71-
72-
NSString * taskId;
73-
int expectedBytes;
74-
int receivedBytes;
75-
NSMutableData * respData;
76-
RCTResponseSenderBlock callback;
77-
RCTBridge * bridge;
78-
NSDictionary * options;
79-
FetchBlobFS * fileStream;
80-
}
81-
@property (nonatomic) NSString * taskId;
82-
@property (nonatomic) int expectedBytes;
83-
@property (nonatomic) int receivedBytes;
84-
@property (nonatomic) NSMutableData * respData;
85-
@property (nonatomic) RCTResponseSenderBlock callback;
86-
@property (nonatomic) RCTBridge * bridge;
87-
@property (nonatomic) NSDictionary * options;
88-
@property (nonatomic) FetchBlobFS * fileStream;
89-
90-
91-
- (id) init;
92-
- (void) sendRequest;
93-
94-
+ (NSMutableDictionary *) normalizeHeaders;
95-
96-
97-
@end
98-
9911

10012
@interface RNFetchBlob : NSObject <RCTBridgeModule> {
10113

@@ -106,7 +18,6 @@ extern NSString *const FS_EVENT_ERROR;
10618
@property (nonatomic) NSString * filePathPrefix;
10719

10820

109-
11021
@end
11122

11223
#endif /* RNFetchBlob_h */

0 commit comments

Comments
 (0)