Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.4.0

Request #17050 Detect MIME-types in stream wrapper
Submitted: 2010-02-01 02:17 UTC
From: schmidt Assigned:
Status: Open Package: Services_Amazon_S3 (version CVS)
PHP Version: Irrelevant OS:
Roadmaps: (Not assigned)    
Subscription  


 [2010-02-01 02:17 UTC] schmidt (Christian Schmidt)
Description: ------------ When files uploaded to S3 are to be downloaded using a regular web browser, a proper Content-Type header should be specified during upload. When files are saved using the stream wrapper interface, there is no standardized way for applications to specify the MIME-type, so the wrapper should somehow detect it. The MIME_Type package supports MIME-type detection detection based on either the file contents (MIME_Type::autoDetect()) or file name extension (MIME_Type_Extension::getMIMEType()). I suggest basing the auto-detection on that package. I imagine that the user can specify which of the two methods to use. In addition to this, the user may be able to specify a custom callback function that detects the MIME-type. Or he can manually supply a MIME-type using the stream context, like this (not tested): $context = stream_context_create(array('s3' => array('content_type' => 'text/xml; charset=UTF-8'))); file_put_contents('s3://foo.xml', $data, 0, $context);

Comments

 [2010-02-01 02:18 UTC] schmidt (Christian Schmidt)
Turns out the last suggestion wrt content_type is such a good idea that it has already been implemented :-)