Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added DownloadFile alias #273

Merged
merged 2 commits into from
Jul 2, 2015
Merged

Conversation

Redth
Copy link
Contributor

@Redth Redth commented Jul 2, 2015

I do a lot of downloading of external files in my build scripts.

This adds a new HttpAliases class with (so far) a single DownloadFile(string url, DirectoryPath outputPath) alias which does exactly what it looks like.

Eventually there could be more HTTP related aliases here such as DownloadString

// We track the last posted value since the event seems to fire many times for the same value
var percentComplete = 0;

var http = new System.Net.WebClient();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we're using this in a sync fashion we should wrap in a using block, so streams/responses gets deallocated.

@devlead
Copy link
Member

devlead commented Jul 2, 2015

@Redth hi looks good just left one comment.

@devlead
Copy link
Member

devlead commented Jul 2, 2015

@Redth Looks good, I'll take a look later to day and merge if I don't find anything else.

@devlead devlead merged commit 8a8392b into cake-build:develop Jul 2, 2015
@RichiCoder1
Copy link
Contributor

Random idea would also be an alias which does the same thing, but drops it in the appropriate "temp" directory and passed back a path/IFilePath. Fun food for thought.

@patriksvensson
Copy link
Member

I like @RichiCoder1's idea as well. Ok if I add tomorrow?

@devlead
Copy link
Member

devlead commented Jul 3, 2015

@RichiCoder1 @patriksvensson download string / bytes would be nice additions to. if your at it;)

@patriksvensson
Copy link
Member

Well, download a file as string/byte feels unsafe. Wouldn't it be better to
return a stream in that case and add convenience methods to convert that to
string/byte array? That way, everyone will opt in for that functionality
instead of doing it like that by mistake.
On Jul 3, 2015 16:24, "Mattias Karlsson" notifications@github.com wrote:

@RichiCoder1 https://github.com/RichiCoder1 @patriksvensson
https://github.com/patriksvensson download string / bytes would be nice
additions to. if your at it;)


Reply to this email directly or view it on GitHub
#273 (comment).

@devlead
Copy link
Member

devlead commented Jul 3, 2015

@patriksvensson methods allready exists on the standard .net WebClient which this pr uses
string DownloadString(String) and byte[] DownloadData(string address)
so would be easy to add aliases for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants