]> source.dussan.org Git - nextcloud-server.git/commitdiff
add header 'OC-FileId' on PUT
authorThomas Müller <thomas.mueller@tmit.eu>
Fri, 25 Oct 2013 11:20:59 +0000 (13:20 +0200)
committerThomas Müller <thomas.mueller@tmit.eu>
Fri, 25 Oct 2013 11:20:59 +0000 (13:20 +0200)
lib/private/connector/sabre/filesplugin.php

index ac781825672cdbe28a5b2bac44ba0c27e6df6430..89444cb8d18a8b83f39646e94b749b86ee53c3cf 100644 (file)
@@ -40,6 +40,8 @@ class OC_Connector_Sabre_FilesPlugin extends Sabre_DAV_ServerPlugin
 
                $this->server = $server;
                $this->server->subscribeEvent('beforeGetProperties', array($this, 'beforeGetProperties'));
+               $this->server->subscribeEvent('afterCreateFile', array($this, 'sendFileIdHeader'));
+               $this->server->subscribeEvent('afterWriteContent', array($this, 'sendFileIdHeader'));
        }
 
        /**
@@ -70,4 +72,18 @@ class OC_Connector_Sabre_FilesPlugin extends Sabre_DAV_ServerPlugin
 
        }
 
+       /**
+        * @param $filePath
+        * @param Sabre_DAV_INode $node
+        * @throws Sabre_DAV_Exception_BadRequest
+        */
+       public function sendFileIdHeader($filePath, Sabre_DAV_INode $node = null) {
+               if ($node instanceof OC_Connector_Sabre_Node) {
+                       $fileId = $node->getFileId();
+                       if (!is_null($fileId)) {
+                               $this->server->httpResponse->setHeader('OC-FileId', $fileId);
+                       }
+               }
+       }
+
 }