summaryrefslogtreecommitdiffstats
path: root/apps/dav/lib/Connector/Sabre/FilesPlugin.php
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2016-09-09 12:19:29 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2016-11-02 22:15:03 +0100
commit6a4ea2c15adb254291b095cfe21818aa28c26138 (patch)
treeef9a606eb82f486254126118ebde6a9851d30888 /apps/dav/lib/Connector/Sabre/FilesPlugin.php
parentc1feae1684934bb52b1edaa67d33d01b377b875a (diff)
downloadnextcloud-server-6a4ea2c15adb254291b095cfe21818aa28c26138.tar.gz
nextcloud-server-6a4ea2c15adb254291b095cfe21818aa28c26138.zip
Upload autorename on client side
Removes the need for POST to collection which would hit against upload limits. The client tries to auto rename the file by adding a suffix "(2)". It tries to use the file list on the client side to guess a suitable name. In case a file still cannot be uploaded and creates a conflict, which can happen when the file was concurrently uploaded, the logic will continue increasing the suffix.
Diffstat (limited to 'apps/dav/lib/Connector/Sabre/FilesPlugin.php')
-rw-r--r--apps/dav/lib/Connector/Sabre/FilesPlugin.php50
1 files changed, 0 insertions, 50 deletions
diff --git a/apps/dav/lib/Connector/Sabre/FilesPlugin.php b/apps/dav/lib/Connector/Sabre/FilesPlugin.php
index 39d15e0c6e9..539e22296f2 100644
--- a/apps/dav/lib/Connector/Sabre/FilesPlugin.php
+++ b/apps/dav/lib/Connector/Sabre/FilesPlugin.php
@@ -172,8 +172,6 @@ class FilesPlugin extends ServerPlugin {
$this->server = $server;
$this->server->on('propFind', array($this, 'handleGetProperties'));
$this->server->on('propPatch', array($this, 'handleUpdateProperties'));
- // RFC5995 to add file to the collection with a suggested name
- $this->server->on('method:POST', [$this, 'httpPost']);
$this->server->on('afterBind', array($this, 'sendFileIdHeader'));
$this->server->on('afterWriteContent', array($this, 'sendFileIdHeader'));
$this->server->on('afterMethod:GET', [$this,'httpGet']);
@@ -435,52 +433,4 @@ class FilesPlugin extends ServerPlugin {
}
}
}
-
- /**
- * POST operation on directories to create a new file
- * with suggested name
- *
- * @param RequestInterface $request request object
- * @param ResponseInterface $response response object
- * @return null|false
- */
- public function httpPost(RequestInterface $request, ResponseInterface $response) {
- // TODO: move this to another plugin ?
- if (!\OC::$CLI && !\OC::$server->getRequest()->passesCSRFCheck()) {
- throw new BadRequest('Invalid CSRF token');
- }
-
- list($parentPath, $name) = \Sabre\HTTP\URLUtil::splitPath($request->getPath());
-
- // Making sure the parent node exists and is a directory
- $node = $this->tree->getNodeForPath($parentPath);
-
- if ($node instanceof Directory) {
- // no Add-Member found
- if (empty($name) || $name[0] !== '&') {
- // suggested name required
- throw new BadRequest('Missing suggested file name');
- }
-
- $name = substr($name, 1);
-
- if (empty($name)) {
- // suggested name required
- throw new BadRequest('Missing suggested file name');
- }
-
- // make sure the name is unique
- $name = basename(\OC_Helper::buildNotExistingFileNameForView($parentPath, $name, $this->fileView));
-
- $node->createFile($name, $request->getBodyAsStream());
-
- list($parentUrl, ) = \Sabre\HTTP\URLUtil::splitPath($request->getUrl());
-
- $response->setHeader('Content-Location', $parentUrl . '/' . rawurlencode($name));
-
- // created
- $response->setStatus(201);
- return false;
- }
- }
}