Example #1
0
 /**
  * Delete a page
  *
  * @param string $pageUID
  * @throws IOException If the page does not exists
  * @return boolean If page is deleted
  */
 public function delete($pageUID)
 {
     $pageFullPath = $pageUID . $this->fileExtension;
     $fs = new Files($this->folder);
     return $fs->delete($pageFullPath);
 }
Example #2
0
        $basename = $info->getBasename('.' . $ext);
        if (in_array($ext, $config->get('upload.evilExtensions'))) {
            $ext = 'txt';
        }
        // Name should be unique // TODO
        $filename = $basename . '.' . $ext;
        $file->moveTo(_UPLOADS_ . $filename);
    } catch (RuntimeException $e) {
        return $this->api->json($res, ['error' => 'UploadException', 'message' => $e->getMessage()], 500);
    }
    return $this->api->json($res, ['filename' => $filename, 'directory' => _UPLOADS_], 201);
});
/**
 * @api {delete} /files/:file delete file
 * @apiName Delete File
 * @apiGroup Files
 *
 * @apiParam {String} file File path to delete
 *
 * @apiSuccess (204) FileDeleted File deleted
 * @apiError (404) CannotBeDeleted File cannot be deleted
 */
$this->delete('/{file:.+}', function ($req, $res, $args) use($fs) {
    try {
        $file = urldecode($args['file']);
        $result = $fs->delete($file);
    } catch (Exception $e) {
        return $this->api->json($res, ['error' => 'CannotBeDeleted', 'message' => $e->getMessage()], 404);
    }
    return $res->withStatus(204);
});