protected function getDirectLink(Request $request, FileManager $fileManager)
 {
     if (!$request->query->has('path')) {
         return $this->abort(400);
     }
     $path = $fileManager->getAbsolutePath($request->query->get('path'));
     if (!is_file($path)) {
         return $this->abort(404);
     }
     if (!$fileManager->isWritable()) {
         return $this->abort(500);
     }
     $relativePath = $fileManager->getRelativePath($path);
     list($parentPath) = explode('/', $relativePath);
     $sharings = Sharing::loadByPathRecursively($parentPath, $fileManager->getOwnerId());
     if (count($sharings) > 0) {
         $sharing = $sharings[0];
     } else {
         $sharing = new Sharing(null, $fileManager->getOwnerId(), $relativePath);
         $sharing->save();
     }
     $sharingPath = $sharing->getPath();
     if (is_file($fileManager->getAbsolutePath($sharingPath))) {
         $sharingPath = dirname($sharingPath);
         if ($sharingPath === '.') {
             $sharingPath = '';
         }
     }
     $finalPath = str_replace($sharingPath, '', $relativePath);
     $url = $this->url('openFile', ['token' => $sharing->getToken(), 'path' => $finalPath], 'sharings_');
     return $this->success($url);
 }