Amazon s3 对pdf文件的内容类型限制在基于浏览器的上传到s3时不起作用

Amazon s3 对pdf文件的内容类型限制在基于浏览器的上传到s3时不起作用,amazon-s3,Amazon S3,内容类型限制在amazon s3发布策略中不起作用: 使用此策略,我可以上载任何类型的文件,我必须仅限制pdf文件 下面是我的代码: $bucket = 'test'; // the name you've chosen for the bucket $key = 'upload/${filename}'; $success_action_redirect = 'localhost/test.html'; $content_type = 'applicatio

内容类型限制在amazon s3发布策略中不起作用: 使用此策略,我可以上载任何类型的文件,我必须仅限制pdf文件

下面是我的代码:

    $bucket = 'test'; // the name you've chosen for the bucket
    $key = 'upload/${filename}'; 
    $success_action_redirect = 'localhost/test.html'; 
    $content_type = 'application/pdf';
    $acl = 'private'; 

   $policy = '
     { "expiration": "2016-08-23T12:00:00.000Z",
       "conditions": [
          {"bucket": "'.$bucket.'"},
          ["starts-with", "$key", ""],
          {"acl": "'.$acl.'"},
          {"success_action_redirect": "'.$success_action_redirect.'"},
          ["starts-with", "$Content-Type", "'.$content_type.'"],
          {"x-amz-meta-uuid": "14365123651274"},
          ["starts-with", "$x-amz-meta-tag", ""],
          ["content-length-range", 0, 10485760]
       ]
    }';

    <form action="bucketUrl" method="post" enctype="multipart/form-data" 
     id="s3-post">
    <input type="hidden" name="key" value="<?php echo $key; ?>">
    <input type="hidden" name="acl" value="<?php echo $acl; ?>">
    <input type="hidden" name="success_action_redirect" value="<?php echo $success_action_redirect; ?>">
    <input type="hidden" name="Content-Type" value="<?php echo $content_type; ?>">
    <input type="hidden" name="x-amz-meta-uuid" value="14365123651274">
    <input type="hidden" name="x-amz-meta-tag" value="">
    <input type="hidden" name="AWSAccessKeyId" value="<?php echo $aws_access_key; ?>">
    <input type="hidden" name="Policy" value="<?php echo base64_encode($policy); ?>">
    <input type="hidden" name="Signature" value="<?php echo base64_encode(hash_hmac('sha1', base64_encode($policy), $aws_secret_key, true)); ?>">
    <input type="file" name="file" class="input_file">
    <input type="submit" name="submit" class="s3_upload" value="Upload to Amazon S3">
$bucket='test';//为存储桶选择的名称
$key='upload/${filename}';
$success\u action\u redirect='localhost/test.html';
$content_type='application/pdf';
$acl='private';
$policy='1
{“到期”:“2016-08-23T12:00:00.000Z”,
“条件”:[
{“bucket”:“.$bucket.”,
[“以“,”$key“,”“”开头],
{“acl”:“'.$acl.”,
{“success\u action\u redirect”:“.$success\u action\u redirect.”,
[“以”、“$Content Type”、“.$Content_Type.”开头],
{“x-amz-meta-uuid”:“14365123651274”},
[“以”、“$x-amz-meta-tag”、”“”开头],
[“内容长度范围”,0,10485760]
]
}';