-
-
Save ahoward/56e39e60f00289625f84 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
s3Uploader.content_type_for = function(file_input, file_name, content_type){ | |
content_type = content_type || 'application/octet-stream'; | |
try{ | |
content_type = jQuery(file_input).prop('files')[0]['type'] | |
} catch(e) {}; | |
if(!content_type){ | |
var parts = file_name.split('.'); | |
var base = parts.shift(); | |
var ext = parts.pop().toLowerCase().trim(); | |
switch(ext){ | |
case 'jpg': | |
case 'jpeg': | |
content_type = 'image/jpeg'; | |
break; | |
case 'png': | |
content_type = 'image/png'; | |
break; | |
case 'gif': | |
content_type = 'image/gif'; | |
break; | |
case 'tiff': | |
case 'tif': | |
content_type = 'image/tiff'; | |
break; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment