public function handleAction(FileManager $fileManager, Request $request, $action)
    {
        $response = new Response();
        try{
            $dir = $this->getFilePath($fileManager);
            $fileManager->setDir($dir);
            $fileManager->checkPath();
            if($request->getMethod() === 'POST') {
                $this->checkToken($request->get('token'));
            }
            switch($action){
                case FileManager::FILE_DELETE:
                    $fileManager->deleteFile();
                    break;
                case FileManager::FILE_MOVE:
                    $fileManager->moveFile();
                    break;
                case FileManager::FILE_EXTRACT:
                    $fileManager->extractZip();
                    break;
                case FileManager::FILE_RENAME:
                    $fileManager->renameFile();
                    break;
                case FileManager::FILE_NEW_DIR:
                    $fileManager->newDirectory();
                    break;
                case FileManager::FILE_COPY:
                case FileManager::FILE_CUT:
                    $this->copyFile($action);
                    break;
                case FileManager::FILE_PASTE:
                    $this->pasteFile();
                    break;
                case FileManager::FILE_INFO:
                    $response = new JsonResponse();
                    $response->setData(json_encode($fileManager->getCurrentFile()->toArray()));
                    break;
            }
        } catch(\Exception $e){
            $response->setContent($e->getMessage());
            $response->setStatusCode($e->getCode() == null ? 500 : $e->getCode());
        }
        return $response;
    }