public function queryobj($token, $type, $objid) { $ret = array('ret' => 4, 'msg' => 'query object token invalid!'); $token_c = new \lib\Token_Core(); $offset = 0; if ($token_c->is_token($token)) { if (APP_DEBUG) { file_put_contents('/var/log/nginx/chdserver.log', $token . '|queryobj|' . $objid . '|' . $type . PHP_EOL, FILE_APPEND | LOCK_EX); } $user = new UserService(); $upload = $user->queryUserUploadId(session('userid'), $objid); if (isset($upload['uploadid'])) { $ret['ret'] = 0; $ret['msg'] = ''; $offset = $upload['offset']; } else { $ret['ret'] = 3; $ret['msg'] = 'query object failed,not exist in upload list!'; } } $ret_h = new \proto\RetHead($ret); $ret_qur = new QueryUpldObjResult(array('result' => $ret_h, 'offset' => $offset)); return $ret_qur; }
public function deleteObject($bucket_name, $object_name) { $Connection = isset($this->ceph_conn) ? $this->ceph_conn : $this->connectionCeph(); $user = new UserService(); $fileinfo = self::queryFile($bucket_name, ${$object_name}); if ($Connection->if_object_exists($bucket_name, $object_name)) { $res = $Connection->delete_object($bucket_name, $object_name); if (!$res->isOK()) { return false; } } elseif ($Connection->if_object_exists($bucket_name, $object_name . '~')) { $upload = $user->queryUserUploadId(session('userid'), $object_name); $Connection->abort_multipart_upload($bucket_name, $object_name . '~', $upload['uploadid']); $res = $Connection->delete_object($bucket_name, $object_name . '~'); if (!$res->isOK()) { return false; } } $user->deleteUserUploadMarker(session('userid'), $object_name); $part_file_path = session('user_upload_path') . DIRECTORY_SEPARATOR . $object_name . '~' . DIRECTORY_SEPARATOR; removeFile($part_file_path); if ($fileinfo['status'] == 0) { $filesize = $fileinfo['filesize']; $user_space = $user->querySpace(session('userid')); $user->updateUserUspace(session('userid'), $user_space['uspace'] - intval($filesize)); } return true; }