bezzad / Downloader

Fast, cross-platform and reliable multipart downloader with asynchronous progress events for .NET applications.
MIT License
1.25k stars 193 forks source link

Resume download with a different URL #136

Closed UrbanCMC closed 1 year ago

UrbanCMC commented 1 year ago

I'm currently trying to integrate your library into a project I'm using, but some of the URLs that are used are generated through an API that gives them an expiration date.

Would it be possible to extend the DownloadFileTaskAsync method to accept a new URL in addition to the download package, or do you foresee any problems with this?

hankb299 commented 1 year ago

Sure I will. What do I need to do exactly?

bezzad commented 1 year ago

This feature was added to the new version 3.0.6. Please check it and add a new issue if you find a problem.

How to use:

var url =  "your_first_link_of_download_file";
var newUrl =  "your_first_link_of_download_file";

var downloader = new DownloadService(config);
await downloader.DownloadFileTaskAsync(url).ConfigureAwait(false);

// resume after canceling upper download
await downloader.DownloadFileTaskAsync(downloader.Package, newUrl);