Add DownloadFile task#3297
Conversation
* Supports cancellation * Supports retries (off by default) * Supports skipping download if file is up-to-date (on by default) * Supports getting file name from URL if possible * Has output parameter with downloaded path
| // Not all URIs contain a file name so users will have to specify one | ||
| // Example: http://www.download.com/file/1/ | ||
|
|
||
| filename = !String.IsNullOrWhiteSpace(DestinationFileName?.ItemSpec) |
There was a problem hiding this comment.
Could we call TrygetFileName after we have recieved the headers?
Precedence (descending order):
DestinationFileName(user-specified)client.ResponseHeaders["content-disposition"], ifDestinationFileNameis emptyurl.LocalPath, ifDestinationFileNameis empty andclient.ResponseHeaders["content-disposition"]is non-empty and meaningful (<file-name>.<extension>format)
so we can call urls like https://lorempizza.com/380/240, we get this kind of filename from response header: imagedoc-darknoise.png (instead of 240)
|
@jeffkl, first of all kudos on the good HttpClient synchronous implementation with the disposables in correct place! 👍 I have left one comment about content disposition, which @CZEMacLeod mentioned in #3220. Secondly, this utility is good as it is, we can safely say that it addresses #3219.
True, that is #3220, we can discuss it separately to make |
|
Only concern I had here is the One thought that's not a great solution but could help is always download when under a certain size or content type? |
|
@AndyGerlicher I don't know how you would store the information, but similarly to the Content-Disposition, perhaps the caching headers could get used, and/or store the ETag? Could they get stored in alternate streams on the file, or is that too platform specific? Some kind of metadata cache file would allow for this. If the file exists, you could use the last updated date and add the If-Modified-Since header to prevent downloading the file again... Or use the info about when it last downloaded from the aforementioned metadata. |
|
I found a If the property is not set, then it will download the file again. |
|
Does it support download via other protocols than http(s), such as FTP or SMB/CIFS? |
Not at the moment, it only supports HTTP endpoints |
But it is possible that it is added later? |
|
@magol possibly. This currently does a simple non-authenticated HTTP GET. If you need more functionality, please feel free to contribute. |
Fixes #3219
Follow-up items: