milesj/cake-uploader — pull request #55 by noahm (2012-05-10 03:33:09+00:00)
Title: Importing remote files with missing extensions or query parameters doesn't work

The following image URLs won't work with the current importRemote function:

* http://dribbble.com/system/users/5146/screenshots/552346/echo2.png?1336574232
(query parameter)
* http://i.imgur.com/nJtQ2.jpg
(incorrect extension)
* http://www.gravatar.com/avatar/987535dd8cc3b678c0c9bc6d3c1de34b
(missing extension)

This pull request strips off query parameters from the URL when determining a filename. Using cURL to fetch the file allows us to use the mimetype from the network request instead of the local filesystem. Finally, if the URL has no file extension, it will try to pick an appropriate one based on the mimetype.