amazonwebservices/aws-sdk-for-php — pull request #33 by bradydoll (2012-07-18 00:01:47+00:00)
Title: Fixed invalid detection of MIME type with upper case file extensions.

When using the S3->create_object() function with the 'fileUpload' option without manually setting the 'contentType', if the file path passed with this option has an extension with either all caps or mixed case, then the file will always be detected as the 'application/octect-stream' MIME type. This is due to this block of code in the s3.class.php file (line 735):
```php
$extension = explode('.', $opt['fileUpload']);
$extension = array_pop($extension);
$mime_type = CFMimeTypes::get_mimetype($extension);
$headers['Content-Type'] = $mime_type;
```

The extension is pulled straight from the fileUpload option and passed to the CFMimeTypes::get_mimetype() function.

That function is relatively simple:
```php
public static function get_mimetype($ext)
{
return (isset(self::$mime_types[$ext]) ? self::$mime_types[$ext] : 'application/octet-stream');
}
```
Just check if the extension exists in the $mime_types array. However, all of the array keys are lower case so an upper or mixed case extension will never match.

A simple fix, included in my pull request, is to change the function CFMimeTypes::get_mimetype() to:
```php
public static function get_mimetype($ext)
{
$ext = strtolower( $ext ); // Make sure the passed extension is lowercase
return (isset(self::$mime_types[$ext]) ? self::$mime_types[$ext] : 'application/octet-stream');
}
```
This will ensure that the check happens with a lowercase extension and resolves the MIME detection error.

I've also included the files _samples/s3_mime_error.php and _samples/test_files/plain2.TXT (which is just a copy of plain.txt), which demonstrate the issue.