public static function getZipInfo($fileList = array(), $saveas = '') { require_once __DIR__ . '/../qiniu/http.php'; require_once __DIR__ . '/../qiniu/auth_digest.php'; require_once __DIR__ . '/../qiniu/utils.php'; $fops = 'mkzip/2'; $extraKey = null; // var_export($fileList); foreach ($fileList as $key => $value) { if (preg_match('/^http:\\/\\//', $value)) { if (is_int($key)) { $fops .= '/url/' . Qiniu_Encode($value); } else { $fops .= '/url/' . Qiniu_Encode($value); // $fops .= '/alias/'.Qiniu_Encode($key); // var_export($key); // var_export(Qiniu_Encode($key)); $fops .= '/alias/' . Qiniu_Encode($key); } if ($extraKey == null) { $extraKey = $value; } } } if ($saveas == null) { $saveas = md5($fops) . '.zip'; } if ($saveas != null) { $fops .= '|saveas/' . Qiniu_Encode(W2Config::$Qiniu_bucket . ':' . $saveas); } $persistentKey = 'mkzip.' . $saveas . '.pfop'; $saveFileInfo = W2Qiniu::getFileInfoFromQiniu($saveas); if (is_array($saveFileInfo) && array_key_exists('fsize', $saveFileInfo)) { return $saveFileInfo; } $persistentId = W2Qiniu::getKeyContent($persistentKey); if (!is_null($persistentId)) { return W2Qiniu::getPersistentInfo($persistentId); } if (strpos($extraKey, W2Config::$Qiniu_domain) != false) { $extraKey = str_replace('http://' . W2Config::$Qiniu_domain . '/', '', $extraKey); } $notifyURL = ""; $force = 0; $encodedBucket = urlencode(W2Config::$Qiniu_bucket); $encodedKey = urlencode($extraKey); $encodedFops = urlencode($fops); $encodedNotifyURL = urlencode($notifyURL); $apiHost = "http://api.qiniu.com"; $apiPath = "/pfop/"; $requestBody = "bucket={$encodedBucket}&key={$encodedKey}&fops={$encodedFops}¬ifyURL={$encodedNotifyURL}"; if ($force !== 0) { $requestBody .= "&force=1"; } $mac = new Qiniu_Mac(W2Config::$Qiniu_accessKey, W2Config::$Qiniu_secretKey); $client = new Qiniu_MacHttpClient($mac); list($ret, $err) = Qiniu_Client_CallWithForm($client, $apiHost . $apiPath, $requestBody); if ($err !== null) { var_dump($err); } else { if (is_array($ret) && array_key_exists('persistentId', $ret)) { W2Qiniu::setKeyContent($persistentKey, $ret['persistentId']); return W2Qiniu::getPersistentInfo($ret['persistentId']); } return $ret; } }