Are Amazon S3 files uploaded using the AWS SDK for PHP always an app / octet stream?

According to docs, contentType is optional, and it will try to determine the correct mime type based on the file extension. However, he never guessed the mime type and always used application / octet-stream by default

Here is my code:

$s3 = new AmazonS3();

$opt = array(   'fileUpload'    => $_FILES['file']['tmp_name'],
                'storage'       => Amazons3::STORAGE_REDUCED);

$r = $s3->create_object('mybucket', $_FILES['file']['name'], $opt);

Here is a screenshot of my AWS console:

enter image description here

How do you automatically set the correct content type without setting the contentType parameter, or do you really need to set it manually?

: ( SDK), , Content-Type (: image/gif GIF /-)

+5
2

contentType 'body' 'fileUpload'. :

$s3->create_object('MY_BUCKET', 'xml_file.xml', array(
                                        'body' => '<xml>Valid xml content</xml>',
                                        'contentType' => 'text/xml'
                                    ));

text/xml. , Content-Type SDK. mime- PHP- contentType?

+6

, Content-Type . , , , SDK. , CFMimeTypes:: get_mimetype(), Content-Type, MIME. - . - , MIME "application/octet-stream".

:

'fileUpload'    => $_FILES['file']['tmp_name']

'fileUpload'    => strtolower( $_FILES['file']['tmp_name'] )

SDK v 1.5.8.2, 1.5.9 1.5.10, . , , .

+1

All Articles