heikowi / hwifiledownload Goto Github PK
View Code? Open in Web Editor NEWHWIFileDownload simplifies file download with NSURLSession on iOS.
License: Other
HWIFileDownload simplifies file download with NSURLSession on iOS.
License: Other
hello
im working with audio library,
when it playing the song,
it download the played song in the background ,
my question is that when i press in download button using your library, can the library take or resume the same already download file of the player and continue for what it pause or done
Hey,
Great work on this. I wanted to find out if HWIFileDownloader Init can fail? If not I will submit a PR to fix that for swift. I checked the code and it didn't seem like it could.
Cheers
geat work
but could you plz add the ability to see the remaining time for each downloaded item
Hi,
HWIFileDownload
is awesome, thanks for making it available!
Is there any, besides a patch, to specify the NSURLSession.delegateQueue
? I notice that you set it to [NSOperationQueue mainQueue]
in the HWIDownloader
initializers. However, we are using HWI from Unity and want to avoid interrupting the main queue when possible. Could we add an option to specify the queue or at least specify that it should create a new serial/concurrent queue other than the main queue?
I could receive HWIDownloadDelegate
calls on the main thread and then immediately dispatch them to another thread, but that would mean that all of HWIDownloader
's non network work would still be done on the main thread since its callbacks from NSURLSession
happen on the main thread (by virtue of the delegate queue).
Any ideas?
Thanks!
@Heikowi hello,
could you plz write a migration document for how we can migrate from version 2 to version 3,
thank you
Hi,
I am using HWIFileDownload and it is great, thanks for making it!
Though i have a one small problem. I get this error from costumers and i only have logs. Sadly i can't reproduce this issue, so i have no clue why it is happening.
ERR: Download with error -1008 (http status: 200)
It happens in didCompleteWithError
NSURLSessionTaskDelegate and its because finalLocalFileURL is nil. I have no idea why it becomes nil in any situation.
Did anybody experience this? I would love to get more information about this error. Thanks in advance!
can you plz add a block style ,
it will be very easy to use
Thx for the Demo,I add a property for the DemoDownloadItem interface, after I download the file ,I wanna store the filePath for every DemoDownloadItem. Could u pls tell me how to implement it? And I wanna initialize the downloadItemsArray from the internet ,maybe not 11 pieces of datas , I wanna know how to apply the downloadIdentifier for every item?
@Heikowi
i always put a identifer as number
but the downloaded filename is like this
063BF1C1-EFF9-4E66-8EB1-20FF24368A55.mp3
how its generated, and how i can changed ?
thank you
I'm getting thread race warnings for HWIFileDownloader.activeDownloadsDictionary
(of type NSMutableDictionary<NSNumber *, HWIFileDownloadItem *>
).
When I open my application, I verify if a certain number of files are downloaded on the device storage (±80 files). For the ones that are missing, I'm starting the download process (in parallel).
The race condition that I get is related to
- (void)startDownloadWithDownloadToken:(nonnull NSString *)aDownloadToken
fromRemoteURL:(nullable NSURL *)aRemoteURL
usingResumeData:(nullable NSData *)aResumeData
At line 313, we add the aDownloadItem
in the activeDownloadsDictionary
([self.activeDownloadsDictionary setObject:aDownloadItem forKey:@(aDownloadID)];
)
At the same time, on another thread, a download has finished and
- (void)handleSuccessfulDownloadToLocalFileURL:(nonnull NSURL *)aLocalFileURL
downloadItem:(nonnull HWIFileDownloadItem *)aDownloadItem
downloadID:(NSUInteger)aDownloadID
is called. Inside this method, we remove the download item from the activeDownloadsDictionary
([self.activeDownloadsDictionary removeObjectForKey:@(aDownloadID)];
).
Here's the full Thread Sanitizer output
==================
WARNING: ThreadSanitizer: race on NSMutableDictionary (pid=18849)
Modifying access of NSMutableDictionary at 0x7b08002e6180 by thread T10:
#0 -[__NSDictionaryM setObject:forKey:] <null> (CoreFoundation:x86_64+0x19160b)
#1 -[HWIFileDownloader startDownloadWithDownloadToken:fromRemoteURL:usingResumeData:] <null> (HWIFileDownload:x86_64+0x63ba)
#2 -[HWIFileDownloader startDownloadWithIdentifier:fromRemoteURL:] <null> (HWIFileDownload:x86_64+0x4848)
#3 -[DVTemplateDownloadStore startDownloadForTemplateFileModel:] <null>
#4 -[DVTemplateDownloadStore startDownloadingIncompleteFilesInTemplateArray:] <null>
#5 __52-[DVMainViewController verifyUserTemplatesIntegrity]_block_invoke <null>
#6 __tsan::invoke_and_release_block(void*) <null> (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x676ab)
#7 _dispatch_client_callout <null> (libdispatch.dylib:x86_64+0x3db4)
Previous modifying access of NSMutableDictionary at 0x7b08002e6180 by main thread:
#0 -[__NSDictionaryM removeObjectForKey:] <null> (CoreFoundation:x86_64+0x1912ef)
#1 -[HWIFileDownloader handleSuccessfulDownloadToLocalFileURL:downloadItem:downloadID:] <null> (HWIFileDownload:x86_64+0x1a6fd)
#2 -[HWIFileDownloader URLSession:task:didCompleteWithError:] <null> (HWIFileDownload:x86_64+0x105f9)
#3 __51-[NSURLSession delegate_task:didCompleteWithError:]_block_invoke.182 <null> (CFNetwork:x86_64+0x1bf001)
#4 _dispatch_client_callout <null> (libdispatch.dylib:x86_64+0x3db4)
#5 start <null> (libdyld.dylib:x86_64+0x1540)
Location is heap block of size 32 at 0x7b08002e6180 allocated by main thread:
#0 calloc <null> (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x4a6b2)
#1 class_createInstance <null> (libobjc.A.dylib:x86_64+0xf34f)
#2 -[HWIFileDownloader initWithDelegate:maxConcurrentDownloads:] <null> (HWIFileDownload:x86_64+0x1b4b)
#3 -[HWIFileDownloader initWithDelegate:] <null> (HWIFileDownload:x86_64+0x179f)
#4 __40+[DVTemplateDownloadStore sharedManager]_block_invoke <null>
#5 dispatch_once <null> (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x682d4)
#6 +[DVTemplateDownloadStore sharedManager] <null>
#7 -[TemplateModel isDownloaded] <null>
#8 -[DVMainViewController initTemplateView] <null>
#9 -[DVMainViewController viewWillAppear:] <null>
#10 -[UIViewController _setViewAppearState:isAnimating:] <null> (UIKitCore:x86_64+0x351436)
#11 start <null> (libdyld.dylib:x86_64+0x1540)
Thread T10 (tid=1095123, running) is a GCD worker thread
SUMMARY: ThreadSanitizer: race on NSMutableDictionary (/Applications/Xcode-10.2.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation:x86_64+0x19160b) in -[__NSDictionaryM setObject:forKey:]
==================
I was looking for this solution but I have download and Run this App for First time start download of 1.tiff & 2.tiff. Now put in Background and Terminate Application. Relaunch Application shows "Started with no progress". but doesn't start or resume download for some how.
Steps to reproduce:
Resume data has invalid format with iOS 10 (<= iOS 10.0.2)
http://benscheirman.com/2016/09/resume-data-broken-in-ios-10/
http://stackoverflow.com/questions/39346231/resume-nsurlsession-on-ios10
This error needs to be fixed by Apple. NSProgress handles resume data internally.
Thx for the Demo, I want the download progress to show on UI under below two condition
I just download fine using HWIFileDownload that some of GoDaddy server url that aTotalBytesExpectedToWriteCount return in -1 how to solve it
The downloading progress on the top is increasing but nothing changed in the list. The tasks those were not finished are marked as "cancelled". I think they are still active since they become "completed" in a few minutes.
2016-05-14 14:58:57.921 HWIFileDownload[1521:635410] -[NSProgress setResumingHandler:]: unrecognized selector sent to instance 0x17012b220
2016-05-14 14:58:57.924 HWIFileDownload[1521:635410] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSProgress setResumingHandler:]: unrecognized selector sent to instance 0x17012b220'
*** First throw call stack:
(0x186e2259c 0x1975300e4 0x186e29664 0x186e26418 0x186d2ab6c 0x1000882d0 0x100087654 0x100084dc4 0x10007c0f4 0x18b608d34 0x18b5f1e48 0x18b6086d0 0x18b5c806c 0x18b6021f8 0x18b601898 0x18b5d4fa8 0x18b873f58 0x18b5d3510 0x186dda9ec 0x186dd9c90 0x186dd7d40 0x186d050a4 0x18feaf5a4 0x18b63a3c0 0x100086038 0x197b9ea08)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
hi,
after updating to 8.3
some download link that contain a redirect to direct link wont work ,
crash and restart the app, the resume data is invaid, do you have some ideas to fix this issue?
http://stackoverflow.com/questions/28360750/nsurlsession-with-invalid-resume-data
sometimes after i force close the app,
the download progress lost , and must start from beginning
how i can get the downloaded file path, and how i can control the downloaded filename for the file that i want to download
Hello! How to customize the download file name and path? I can not find the Api. Thank you very much!
Is there any chance of this to be added to Cocoapods? Or would you accept a PR that does this?
in some case the download link expire after certain, time
could you plz add some notification logic maybe, so we can detect if the link sudnely become dead, or its not reponding so i can swtich the new download link
sometime the absoule local file of the downloaded change,
is that normal ,
how i can get the relative path for the file,
could you plz add a method that get get the newset localfile path
Hi!
I am trying to find an elegant solution to prevent my app from downloading 403 pages instead of the right files. I saw in documentation there is an optional delegate method
- (BOOL)httpStatusCode:(NSInteger)aHttpStatusCode isValidForDownloadIdentifier:(nonnull NSString *)aDownloadIdentifier;
but I can not find it.
Any help will be useful.
Thanks!
Hello @Heikowi
It seems to me that version 3.1 of this excellent library does not contain the new option to customize the urlRequest. The 3.1
tag is still on a much older commit than I think it was meant to. If this is intentional, I would love to see a release with the urlRequestForRemoteURL
callback that works on all iOS versions.
Thanks in advance!
hi how i can pause/resume and cancel one download
How can I use this in Swift 4?
Hello @Heikowi ,
Can I implement the download manager in following way?
Like while starting download user can set allowed network type for the specific download item.
Such as wifi and cellular network.
So if the user has selected wifi only for one download item and user switches to cellular then the download will automatically get paused. And when we switch back to wifi so download will get started/resumed
Please let me know
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.