1

I am using amazons s3 upload which has content-type

array('starts-with', '$Content-Type', 'image/'),

ok so this is set to image the problem i am having is when upload a js file with this it adds it to amazon s3 as a image you can view the file here. https://s3.amazonaws.com/s3fileshare.mplayer/lightbox.js

So you can see its a js file but its being uploaded with image settings here is the file if i use amazon s3 built in uploader https://s3.amazonaws.com/s3fileshare.mplayer/test/lightbox.js as you can see that opens fine as a js file.

So what i am asking is how do you set the content-type for all types off files.

// prepare policy
$policy = base64_encode(json_encode(array(
    // ISO 8601 - date('c'); generates uncompatible date, so better do it manually
    'expiration' => date('Y-m-d\TH:i:s.000\Z', strtotime('+1 day')),  
    'conditions' => array(
        array('bucket' => $bucket),
        array('acl' => 'public-read'),
        array('starts-with', '$key', ''),
        // for demo purposes we are accepting only images


       //Vvvvvvvvvv this line below vvvvvvvvvvvV
        array('starts-with', '$Content-Type', 'image/'),
        array('success_action_status' => '201'),
        array('starts-with', '$name', ''),  
        array('starts-with', '$Filename', ''), 
    )
)));

any suggestions

DCHP
  • 1,111
  • 6
  • 29
  • 53
  • 1
    You'd want to use some kind function to detect the content encoding of a file. Check out these: http://stackoverflow.com/questions/652002/detecting-mime-type-in-php http://stackoverflow.com/questions/1232769/how-to-get-the-content-type-of-a-file-in-php http://www.php.net/manual/en/ref.fileinfo.php – Daan Mar 20 '12 at 10:45
  • thanks got it sorted now – DCHP Mar 20 '12 at 11:00
  • 1
    how? i am having the same problem... – bershika Aug 03 '12 at 19:03

0 Answers0