52 lines
1.6 KiB
Objective-C
52 lines
1.6 KiB
Objective-C
// Copyright 2015-present 650 Industries. All rights reserved.
|
|
|
|
#import <EXFileSystem/EXSessionTaskDelegate.h>
|
|
|
|
@implementation EXSessionTaskDelegate
|
|
|
|
- (instancetype)initWithResolve:(UMPromiseResolveBlock)resolve
|
|
reject:(UMPromiseRejectBlock)reject
|
|
{
|
|
if (self = [super init]) {
|
|
_resolve = resolve;
|
|
_reject = reject;
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error
|
|
{
|
|
if (error) {
|
|
self.reject(@"ERR_FILESYSTEM_CANNOT_DOWNLOAD",
|
|
[NSString stringWithFormat:@"Unable to download file: %@", error.description],
|
|
error);
|
|
}
|
|
}
|
|
|
|
- (NSDictionary *)parseServerResponse:(NSURLResponse *)response
|
|
{
|
|
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
|
|
return @{
|
|
@"status": @([httpResponse statusCode]),
|
|
@"headers": [httpResponse allHeaderFields],
|
|
@"mimeType": UMNullIfNil([httpResponse MIMEType])
|
|
};
|
|
}
|
|
|
|
- (void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask didFinishDownloadingToURL:(NSURL *)location
|
|
{
|
|
}
|
|
|
|
- (void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask
|
|
didWriteData:(int64_t)bytesWritten
|
|
totalBytesWritten:(int64_t)totalBytesWritten
|
|
totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite
|
|
{
|
|
}
|
|
|
|
- (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask didReceiveData:(NSData *)data
|
|
{
|
|
}
|
|
|
|
@end
|