[Rd] Suggestion: Change default to download.file(..., mode="wb") ...instead of mode="w" with some bells and whistles

From: Henrik Bengtsson <hb_at_biostat.ucsf.edu>
Date: Wed, 29 Aug 2012 12:27:53 -0700


I keep seeing the problem where people are download binary files as text (mode="w") when using R's download.file() for FTP/HTTP downloads.  It often results in unnecessary troubleshooting until one concludes that the downloaded file has been corrupted due to (what I think is) translated newlines. Search the r-help mailing list and you'll find other examples of this. This may or may not only be a problem for Windows users.

I'd like to suggest to change the default of argument 'mode' of download.file() to be mode="wb". The "default" is current mode="w" except when argument 'mode' is missing (not explicitly given), download.file() tries to be helpful by forcing 'mode' to be "wb" for certain filename extensions. NB: help("download.file", package="utils") has a paragraph on all this. BTW, the latter seems to be done in a case-sensitive way, such that *.zip and *.ZIP will have different behaviors.

Wouldn't it just be safer to change the default to mode="wb"? ...or are there use cases that I'm overseeing - is anyone out there intentionally using the "text" transfer mode?


R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Wed 29 Aug 2012 - 19:30:50 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 05 Sep 2012 - 21:00:42 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive