summaryrefslogtreecommitdiffstats
path: root/lib/connector/sabre/directory.php
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2012-07-08 22:11:13 +0200
committerBart Visscher <bartv@thisnet.nl>2012-07-08 22:11:36 +0200
commite8010209bb1ec8ef9ecc1cff7ac2b2d4d414bd74 (patch)
tree1fab2beb8abfbbf9601499883329ce3cb166842d /lib/connector/sabre/directory.php
parentdc8193fccb7f18435844a3f5d2e79d27b6b7f0a3 (diff)
downloadnextcloud-server-e8010209bb1ec8ef9ecc1cff7ac2b2d4d414bd74.tar.gz
nextcloud-server-e8010209bb1ec8ef9ecc1cff7ac2b2d4d414bd74.zip
Custom chunking support
Diffstat (limited to 'lib/connector/sabre/directory.php')
-rw-r--r--lib/connector/sabre/directory.php29
1 files changed, 25 insertions, 4 deletions
diff --git a/lib/connector/sabre/directory.php b/lib/connector/sabre/directory.php
index b75bb5c50f5..894256d5b2a 100644
--- a/lib/connector/sabre/directory.php
+++ b/lib/connector/sabre/directory.php
@@ -33,10 +33,31 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
* @return void
*/
public function createFile($name, $data = null) {
-
- $newPath = $this->path . '/' . $name;
- OC_Filesystem::file_put_contents($newPath,$data);
-
+ if (isset($_SERVER['HTTP_OC_CHUNKED'])) {
+ $cache = new OC_Cache_File();
+ $cache->set($name, $data);
+ preg_match('/(?P<name>.*)-chunking-(?P<transferid>\d+)-(?P<chunkcount>\d+)-(?P<index>\d+)/', $name, $matches);
+ $prefix = $matches['name'].'-chunking-'.$matches['transferid'].'-'.$matches['chunkcount'].'-';
+ $parts = 0;
+ for($i=0; $i < $matches['chunkcount']; $i++) {
+ if ($cache->hasKey($prefix.$i)) {
+ $parts ++;
+ }
+ }
+ if ($parts == $matches['chunkcount']) {
+ $newPath = $this->path . '/' . $matches['name'];
+ $f = OC_Filesystem::fopen($newPath, 'w');
+ for($i=0; $i < $matches['chunkcount']; $i++) {
+ $chunk = $cache->get($prefix.$i);
+ $cache->remove($prefix.$i);
+ fwrite($f,$chunk);
+ }
+ fclose($f);
+ }
+ } else {
+ $newPath = $this->path . '/' . $name;
+ OC_Filesystem::file_put_contents($newPath,$data);
+ }
}
/**