function SaeStorageGetFileAttr($FilePath) { $storage = new SaeStorage(); $domain = Sae_Storage_Domain_Name; $result = $storage->getAttr($domain, $FilePath); return $result; }
/** * 修改文件处理函数 * * @access public * @param array $content 老文件 * @param array $file 新上传的文件 * @return mixed */ public static function modifyHandle($content, $file) { if (empty($file['name'])) { return false; } $fileName = preg_split("(\\/|\\|:)", $file['name']); $file['name'] = array_pop($fileName); //获取扩展名 $ext = ''; $part = explode('.', $file['name']); if (($length = count($part)) > 1) { $ext = strtolower($part[$length - 1]); } if ($content['attachment']->type != $ext) { return false; } //获取文件名 $fileName = $content['attachment']->path; $path = $path . '/' . $fileName; //add for mkdir $stor = new SaeStorage(); $options = Typecho_Widget::widget('Widget_Options'); $SaeStorageDomain = $options->plugin('SaeUpload')->saestoragedomain; if (isset($file['tmp_name'])) { //移动上传文件 if (!($path = $stor->upload($SaeStorageDomain, $fileName, $file['tmp_name']))) { return false; } } else { if (isset($file['bits'])) { //直接写入文件 if (!($path = $stor->write($SaeStorageDomain, $fileName, $file['bits']))) { return false; } } else { return false; } } if (!isset($file['size'])) { $attr = $stor->getAttr($SaeStorageDomain, $fileName, array('length')); $file['size'] = $attr['length']; } //返回相对存储路径 return array('name' => $content['attachment']->name, 'path' => $content['attachment']->path, 'size' => $file['size'], 'type' => $content['attachment']->type, 'mime' => $content['attachment']->mime); }
/** * * {@inheritDoc} * @see \Illuminate\Contracts\Filesystem\Filesystem::size() */ public function size($path) { list($domain, $path) = $this->parser($path); $info = $this->storage->getAttr($domain, $path); return $info ? $info['length'] : false; }
if (in_array($file_ext, $allow_ext['image']) === true) { $format = 'image'; } else { if (in_array($file_ext, $allow_ext['flash']) === true) { $format = 'flash'; } else { if (in_array($file_ext, $allow_ext['media']) === true) { $format = 'media'; } else { if (in_array($file_ext, $allow_ext['file']) === true) { $format = 'file'; } else { $format = 'unknown'; } } } } $baseInfo = $storage->getAttr($glInfo['domain'], $ret[$i]); $fileInfo[$i]['file_ext'] = $file_ext; $fileInfo[$i]['format'] = $format; $fileInfo[$i]['content_type'] = $baseInfo['content_type']; $fileInfo[$i]['domain'] = $glInfo['domain']; $fileInfo[$i]['filename'] = $baseInfo['fileName']; $fileInfo[$i]['url'] = $storage->getUrl($glInfo['domain'], $ret[$i]); $fileInfo[$i]['length'] = $baseInfo['length']; $fileInfo[$i]['datetime'] = $baseInfo['datetime']; $fileInfo[$i]['md5sum'] = $baseInfo['md5sum']; $fileInfo[$i]['expires'] = $baseInfo['expires']; } } echo json_encode($fileInfo);