Commit 7cade323 authored by Felix Paul Kühne's avatar Felix Paul Kühne

http file downloader: fix storage of loaded file

parent 1b5d62e7
......@@ -36,8 +36,12 @@
- (void)downloadFileFromURL:(NSURL *)url
{
NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *basePath = [searchPaths[0] stringByAppendingPathComponent:@"Upload"];
_fileName = url.lastPathComponent;
_filePath = [[searchPaths[0] stringByAppendingPathComponent:@"Upload"] stringByAppendingPathComponent:_fileName];
_filePath = [basePath stringByAppendingPathComponent:_fileName];
NSFileManager *fileManager = [NSFileManager defaultManager];
if (![fileManager fileExistsAtPath:basePath])
[fileManager createDirectoryAtPath:basePath withIntermediateDirectories:YES attributes:nil error:nil];
_expectedDownloadSize = _receivedDataSize = 0;
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
_urlConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
......@@ -54,8 +58,12 @@
- (void)downloadFileFromURLwithFileName:(NSURL *)url fileNameOfMedia:(NSString*) fileName
{
NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *basePath = [searchPaths[0] stringByAppendingPathComponent:@"Upload"];
_fileName = fileName;
_filePath = [[searchPaths[0] stringByAppendingPathComponent:@"Upload"] stringByAppendingPathComponent:_fileName];
_filePath = [basePath stringByAppendingPathComponent:_fileName];
NSFileManager *fileManager = [NSFileManager defaultManager];
if (![fileManager fileExistsAtPath:basePath])
[fileManager createDirectoryAtPath:basePath withIntermediateDirectories:YES attributes:nil error:nil];
_expectedDownloadSize = _receivedDataSize = 0;
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
_urlConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment