/** * 检测上传根目录 * @return boolean true-检测通过,false-检测失败 */ public function checkRootPath() { $st = new \SaeStorage(); if (false === $st->getDomainCapacity($this->domain)) { $this->error = '您好像没有建立Storage的domain[' . $this->domain . ']'; return false; } return true; }
* 构造函数,设置storage的domain, 如果有传配置,则domain为配置项,如果没有传domain为第一个路径的目录名称。 * @param mixed $config 上传配置 */ public function __construct($config = null) { if (is_array($config) && !empty($config['domain'])) { $this->domain = strtolower($config['domain']); } } /** * 检测上传根目录 * @param string $rootpath 根目录 * @return boolean true-检测通过,false-检测失败 */ public function checkRootPath($rootpath) { $rootpath = trim($rootpath, './');
<?php // 参考: http://apidoc.sinaapp.com/class-SaeStorage.html // 顺便吐槽下,居然没有 createDomain() 的接口,需要开发者手工创建一个 upload 的 domain // 虽然 SAE 很有争议,但是还是有很多开发者想玩一玩,XN3 只需要一个文件配置文件就搞定。正式运营环境建议使用 VPS 或者独立服务器。 if (IN_SAE) { $saestorage = new SaeStorage(); //$saestorage->setDomainAttr('domain', array('private'=>'false')); $n = $saestorage->getDomainCapacity('upload'); //if($n == NULL || $saestorage->errno() == -7) exit('SaeStorage upload 磁盘配额不足!'); if ($n == NULL || $saestorage->errno()) { exit($saestorage->errmsg()); } $conf['db'] = array('type' => 'mysql', 'mysql' => array('master' => array('host' => SAE_MYSQL_HOST_M . (SAE_MYSQL_PORT == 3306 ? '' : ':' . SAE_MYSQL_PORT), 'user' => SAE_MYSQL_USER, 'password' => SAE_MYSQL_PASS, 'name' => SAE_MYSQL_DB, 'charset' => 'utf8', 'engine' => 'MyISAM'), 'slaves' => array())); $conf['upload_url'] = $saestorage->geturl('upload', '') . '/'; $conf['upload_path'] = 'saestor://upload/'; $conf['tmp_path'] = SAE_TMP_PATH; } // 函数如果放在 if 里面不利于 opcode 缓存。 /*function sae_move_upload_file($srcfile, $destfile) { global $saestorage; return $saestorage->upload('upload', $srcfile, $destfile); }*/
function SaeStorageCapacity() { $storage = new SaeStorage(); $domain = Sae_Storage_Domain_Name; $result = $storage->getDomainCapacity($domain); return $result; }