1// Copyright 2015-present 650 Industries. All rights reserved. 2 3#import <ExpoFileSystem/EXSessionTaskDelegate.h> 4 5@implementation EXSessionTaskDelegate 6 7- (nonnull instancetype)initWithResolve:(EXPromiseResolveBlock)resolve 8 reject:(EXPromiseRejectBlock)reject 9{ 10 if (self = [super init]) { 11 _resolve = resolve; 12 _reject = reject; 13 } 14 return self; 15} 16 17- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error 18{ 19 if (error) { 20 self.reject(@"ERR_FILESYSTEM_CANNOT_DOWNLOAD", 21 [NSString stringWithFormat:@"Unable to download file: %@", error.description], 22 error); 23 } 24} 25 26- (NSDictionary *)parseServerResponse:(NSURLResponse *)response 27{ 28 NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response; 29 return @{ 30 @"status": @([httpResponse statusCode]), 31 @"headers": [httpResponse allHeaderFields], 32 @"mimeType": EXNullIfNil([httpResponse MIMEType]) 33 }; 34} 35 36- (void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask didFinishDownloadingToURL:(NSURL *)location 37{ 38} 39 40- (void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask 41 didWriteData:(int64_t)bytesWritten 42 totalBytesWritten:(int64_t)totalBytesWritten 43 totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite 44{ 45} 46 47- (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask didReceiveData:(NSData *)data 48{ 49} 50 51- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task 52 didSendBodyData:(int64_t)bytesSent 53 totalBytesSent:(int64_t)totalBytesSent 54 totalBytesExpectedToSend:(int64_t)totalBytesExpectedToSend 55{ 56} 57 58@end 59