diff --git a/Downloader.h b/Downloader.h index a997921..ca57e37 100644 --- a/Downloader.h +++ b/Downloader.h @@ -17,6 +17,7 @@ typedef void (^ProgressCallback)(NSNumber*, NSNumber*); @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 (copy) NSNumber* progressDivider; +@property (copy) NSNumber* readTimeout; @end diff --git a/Downloader.m b/Downloader.m index ca0a3fd..c0771dc 100644 --- a/Downloader.m +++ b/Downloader.m @@ -51,6 +51,7 @@ } config.HTTPAdditionalHeaders = _params.headers; + config.timeoutIntervalForRequest = [_params.readTimeout intValue] / 1000.0; _session = [NSURLSession sessionWithConfiguration:config delegate:self delegateQueue:nil]; _task = [_session downloadTaskWithURL:url]; diff --git a/README.md b/README.md index 3328684..f3d7af5 100644 --- a/README.md +++ b/README.md @@ -508,7 +508,7 @@ type DownloadFileOptions = { begin?: (res: DownloadBeginCallbackResult) => void; progress?: (res: DownloadProgressCallbackResult) => void; connectionTimeout?: number // only supported on Android yet - readTimeout?: number // only supported on Android yet + readTimeout?: number // supported on Android and iOS }; ``` ``` diff --git a/RNFSManager.m b/RNFSManager.m index 613082f..bd08d63 100755 --- a/RNFSManager.m +++ b/RNFSManager.m @@ -431,6 +431,8 @@ RCT_EXPORT_METHOD(downloadFile:(NSDictionary *)options params.discretionary = [discretionary boolValue]; NSNumber* progressDivider = options[@"progressDivider"]; params.progressDivider = progressDivider; + NSNumber* readTimeout = options[@"readTimeout"]; + params.readTimeout = readTimeout; __block BOOL callbackFired = NO;