Skip to content

Commit e7a39d9

Browse files
committed
Apply fix for #263
1 parent 0060439 commit e7a39d9

File tree

3 files changed

+34
-29
lines changed

3 files changed

+34
-29
lines changed

src/index.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -247,14 +247,12 @@ function fetch(...args:any):Promise {
247247
})
248248

249249
stateEvent = emitter.addListener('RNFetchBlobState', (e) => {
250-
respInfo = e
251-
if(e.taskId === taskId && promise.onStateChange) {
252-
promise.onStateChange(e)
253-
}
250+
if(e.taskId === taskId)
251+
respInfo = e
252+
promise.onStateChange && promise.onStateChange(e)
254253
})
255254

256255
subscription = emitter.addListener('RNFetchBlobExpire', (e) => {
257-
console.log(e , 'EXPIRED!!')
258256
if(e.taskId === taskId && promise.onExpire) {
259257
promise.onExpire(e)
260258
}

src/ios/RNFetchBlobNetwork.h

+18
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323

2424
typedef void(^CompletionHander)(NSURL * _Nullable location, NSURLResponse * _Nullable response, NSError * _Nullable error);
2525
typedef void(^DataTaskCompletionHander) (NSData * _Nullable resp, NSURLResponse * _Nullable response, NSError * _Nullable error);
26+
typedef NS_ENUM(NSUInteger, ResponseFormat) {
27+
UTF8,
28+
BASE64,
29+
AUTO
30+
};
2631

2732
@interface RNFetchBlobNetwork : NSObject <NSURLSessionDelegate, NSURLSessionTaskDelegate, NSURLSessionDataDelegate>
2833

@@ -38,6 +43,19 @@ typedef void(^DataTaskCompletionHander) (NSData * _Nullable resp, NSURLResponse
3843
@property (strong, nonatomic) CompletionHander fileTaskCompletionHandler;
3944
@property (strong, nonatomic) DataTaskCompletionHander dataTaskCompletionHandler;
4045
@property (nullable, nonatomic) NSError * error;
46+
@property (nullable, nonatomic) NSMutableArray * redirects;
47+
48+
@property (nonatomic) BOOL respFile;
49+
@property (nonatomic) BOOL isNewPart;
50+
@property (nonatomic) BOOL isIncrement;
51+
@property (nullable, nonatomic) NSMutableData * partBuffer;
52+
@property (nullable, nonatomic) NSString * destPath;
53+
@property (nullable, nonatomic) NSOutputStream * writeStream;
54+
@property (nonatomic) long bodyLength;
55+
@property (nullable, nonatomic) NSMutableDictionary * respInfo;
56+
@property (nonatomic) NSInteger respStatus;
57+
@property (nonatomic) ResponseFormat responseFormat;
58+
@property ( nonatomic) BOOL followRedirect;
4159

4260

4361
+ (NSMutableDictionary * _Nullable ) normalizeHeaders:(NSDictionary * _Nullable)headers;

src/ios/RNFetchBlobNetwork.m

+13-24
Original file line numberDiff line numberDiff line change
@@ -61,30 +61,6 @@ static void initialize_tables() {
6161
}
6262

6363

64-
typedef NS_ENUM(NSUInteger, ResponseFormat) {
65-
UTF8,
66-
BASE64,
67-
AUTO
68-
};
69-
70-
71-
@interface RNFetchBlobNetwork ()
72-
{
73-
BOOL * respFile;
74-
BOOL isNewPart;
75-
BOOL * isIncrement;
76-
NSMutableData * partBuffer;
77-
NSString * destPath;
78-
NSOutputStream * writeStream;
79-
long bodyLength;
80-
NSMutableDictionary * respInfo;
81-
NSInteger respStatus;
82-
NSMutableArray * redirects;
83-
ResponseFormat responseFormat;
84-
BOOL * followRedirect;
85-
}
86-
87-
@end
8864

8965
@implementation RNFetchBlobNetwork
9066

@@ -96,10 +72,23 @@ @implementation RNFetchBlobNetwork
9672
@synthesize callback;
9773
@synthesize bridge;
9874
@synthesize options;
75+
@synthesize redirects;
9976
@synthesize fileTaskCompletionHandler;
10077
@synthesize dataTaskCompletionHandler;
10178
@synthesize error;
10279

80+
@synthesize respFile;
81+
@synthesize isNewPart;
82+
@synthesize isIncrement;
83+
@synthesize partBuffer;
84+
@synthesize destPath;
85+
@synthesize writeStream;
86+
@synthesize bodyLength;
87+
@synthesize respInfo;
88+
@synthesize respStatus;
89+
@synthesize responseFormat;
90+
@synthesize followRedirect;
91+
10392

10493
// constructor
10594
- (id)init {

0 commit comments

Comments
 (0)