Skip to content

Instantly share code, notes, and snippets.

View ayrton's full-sized avatar

Ayrton ayrton

View GitHub Profile
@ayrton
ayrton / gist:954171
Created May 3, 2011 20:34
Determine file extension based on mimetype
def determine_file_extension_with_mime_type(mimetype)
fe = `grep #{mimetype} -i mime.types`.gsub(mimetype, '').strip.split(' ')[0]
if fe == '' || fe.nil?
''
else
".#{fe}"
end
end