mirror of
https://github.com/status-im/react-native-fs.git
synced 2025-02-28 23:10:29 +00:00
Merge pull request #381 from josephroque/timeout-ios
Respect readTimeout for downloadFile on iOS
This commit is contained in:
commit
f037c79ec9
@ -17,6 +17,7 @@ typedef void (^ProgressCallback)(NSNumber*, NSNumber*);
|
|||||||
@property bool background; // Whether to continue download when app is in background
|
@property bool background; // Whether to continue download when app is in background
|
||||||
@property bool discretionary; // Whether the file may be downloaded at the OS's discretion (iOS only)
|
@property bool discretionary; // Whether the file may be downloaded at the OS's discretion (iOS only)
|
||||||
@property (copy) NSNumber* progressDivider;
|
@property (copy) NSNumber* progressDivider;
|
||||||
|
@property (copy) NSNumber* readTimeout;
|
||||||
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -51,6 +51,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
config.HTTPAdditionalHeaders = _params.headers;
|
config.HTTPAdditionalHeaders = _params.headers;
|
||||||
|
config.timeoutIntervalForRequest = [_params.readTimeout intValue] / 1000.0;
|
||||||
|
|
||||||
_session = [NSURLSession sessionWithConfiguration:config delegate:self delegateQueue:nil];
|
_session = [NSURLSession sessionWithConfiguration:config delegate:self delegateQueue:nil];
|
||||||
_task = [_session downloadTaskWithURL:url];
|
_task = [_session downloadTaskWithURL:url];
|
||||||
|
@ -508,7 +508,7 @@ type DownloadFileOptions = {
|
|||||||
begin?: (res: DownloadBeginCallbackResult) => void;
|
begin?: (res: DownloadBeginCallbackResult) => void;
|
||||||
progress?: (res: DownloadProgressCallbackResult) => void;
|
progress?: (res: DownloadProgressCallbackResult) => void;
|
||||||
connectionTimeout?: number // only supported on Android yet
|
connectionTimeout?: number // only supported on Android yet
|
||||||
readTimeout?: number // only supported on Android yet
|
readTimeout?: number // supported on Android and iOS
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
```
|
```
|
||||||
|
@ -431,6 +431,8 @@ RCT_EXPORT_METHOD(downloadFile:(NSDictionary *)options
|
|||||||
params.discretionary = [discretionary boolValue];
|
params.discretionary = [discretionary boolValue];
|
||||||
NSNumber* progressDivider = options[@"progressDivider"];
|
NSNumber* progressDivider = options[@"progressDivider"];
|
||||||
params.progressDivider = progressDivider;
|
params.progressDivider = progressDivider;
|
||||||
|
NSNumber* readTimeout = options[@"readTimeout"];
|
||||||
|
params.readTimeout = readTimeout;
|
||||||
|
|
||||||
__block BOOL callbackFired = NO;
|
__block BOOL callbackFired = NO;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user