/** * @ApiDoc( * section="File Manager", * description="Moves or copies files in /web to $target in /web" * ) * * @Rest\RequestParam(name="files", requirements=".*", map=true, strict=true, description="The file paths") * @Rest\RequestParam(name="target", requirements=".*", strict=true, description="The target file path") * @Rest\RequestParam(name="overwrite", requirements=".*", strict=true, default="false", description="If the target should be overwritten") * @Rest\RequestParam(name="move", requirements=".*", strict=true, default="false", description="If files should be moved (cut&paste) or copied (copy&paste)") * * @Rest\Post("/admin/file/paste") * * @param ParamFetcher $paramFetcher * * @return array|bool returns [targetExists => true] when a target exists and $overwrite=false, otherwise true/false. */ public function pasteAction(ParamFetcher $paramFetcher) { $files = $paramFetcher->get('files'); $target = $paramFetcher->get('target'); $overwrite = filter_var($paramFetcher->get('overwrite'), FILTER_VALIDATE_BOOLEAN); $move = filter_var($paramFetcher->get('move'), FILTER_VALIDATE_BOOLEAN); $this->checkAccess($target); foreach ($files as $file) { $this->checkAccess($file); $newPath = $target . '/' . basename($file); if (!$overwrite && $this->webFilesystem->has($newPath)) { return ['targetExists' => true]; } $this->newFeed($file, $move ? 'moved' : 'copied', sprintf('from %s to %s', $file, $newPath)); } return $this->webFilesystem->paste($files, $target, $move ? 'move' : 'copy'); }