Пример #1
0
 /**
  * 组装文件需要的post参数
  * @param string $signature
  * @param int $offset
  * @return array
  */
 public static function getPost($signature, $offset = 0)
 {
     $key = substr($signature, 0, 2) . "/" . substr($signature, 2, 2);
     $key .= "/" . substr($signature, 4, 2) . "/" . substr($signature, 6, 2);
     // TODO: 处理组装s3需要的参数
     $input = array("Filename" => "{$signature}", "key" => "{$key}/\${filename}");
     // 生成数字签名,使用json格式,返回hash格式数据
     $output = MUtils::getRequesSignature($input);
     $expirationTime = $output["expiration_date"];
     $digitalSignature = $output["digital_signature"];
     $post = array();
     $post["Filename"] = $signature;
     $post["AWSAccessKeyId"] = MConst::ACCESS_KEY_ID;
     $post["key"] = $signature;
     $post["expiration_date"] = $expirationTime;
     $post["digital_signature"] = $digitalSignature;
     $post["offset"] = $offset;
     $post["success_action_status"] = "201";
     $post["acl"] = "";
     $post["signature"] = "";
     $post["policy"] = "";
     $post = json_encode($post);
     return $post;
 }