Exemplo n.º 1
0
 public function delete()
 {
     $filePath = MiniHttp::getParam('file_path', '');
     LockBiz::getInstance()->delete($filePath);
     return array('success' => true);
 }
Exemplo n.º 2
0
 /**
  * 处理组装请求元数据
  * @param $response
  * @param $file
  * @param $mimeType
  * @return mixed
  */
 private function assembleResponse($response, $file, $mimeType)
 {
     $filePath = $file["file_path"];
     $result = LockBiz::getInstance()->status($filePath);
     $response['lock'] = $result["success"];
     $response["size"] = MUtils::getSizeByLocale($this->locale, $file["file_size"]);
     $response["bytes"] = (int) $file["file_size"];
     $response["path"] = $filePath;
     $response["file_name_pinyin"] = $file['file_name_pinyin'];
     $response["modified"] = MUtils::formatIntTime($file["file_update_time"]);
     $response["create_time"] = $file["file_create_time"];
     $response["update_time"] = $file["file_update_time"];
     $response["revision"] = intval($file["version_id"]);
     $response["rev"] = strval($file["version_id"]);
     $response["root"] = $this->root;
     $response["hash"] = !empty($file["signature"]) ? $file["signature"] : "";
     $response["event"] = $file["event_uuid"];
     $response["sort"] = (int) $file["sort"];
     //外链Key
     $link = MiniLink::getInstance()->getByFileId($file['id']);
     if (empty($link['share_key'])) {
         $response["share_key"] = '';
     } else {
         $response["share_key"] = $link['share_key'];
     }
     $response['is_dir'] = false;
     $permission = UserPermissionBiz::getInstance()->getPermission($filePath, $this->userId);
     if (!empty($permission)) {
         if (isset($permission['children_shared'])) {
             $response['children_shared'] = true;
         } else {
             $permission["share_model"] = $this->getShareModel($filePath);
             $response['share'] = $permission;
         }
         $filePermission = new MiniPermission($permission['permission']);
         $response['canDelete'] = $filePermission->canDeleteFile();
         if (empty($permission['permission'])) {
             return null;
         }
     }
     if ($file["file_type"] == MConst::OBJECT_TYPE_FILE) {
         $mimeType = MiniUtil::getMimeType($file['file_path']);
         $response["thumb_exists"] = MUtils::isExistThumbnail($mimeType, (int) $file["file_size"]);
     } else {
         $response['is_dir'] = true;
     }
     if ($file["file_type"] > MConst::OBJECT_TYPE_FILE) {
         $response["type"] = (int) $file["file_type"];
     }
     if (!empty($mimeType)) {
         $response["mime_type"] = $mimeType;
     }
     if ($file["is_deleted"] == true) {
         $response["is_deleted"] = true;
     }
     return $response;
 }