/**
  * uploadFileStream
  * 
  * Ladet eine Datei in den virtuellen Datenspeicher hoch
  *
  * @param string		$fp				Filestream der hochzuladenden Datei
  * @param string		$newfile		Pfad und Name der neuen Datei innerhalb des virtuellen Datenspeichers
  */
 function uploadFileStream($fp, $newfile)
 {
     $path = $this->ext_root . "/" . $newfile;
     //Verschlüsselung
     if ($this->crypto_key != null) {
         $this->csp_encryptStream($fp, $this->crypto_key);
     }
     $result = $this->dbxClient->uploadFile($path, \Dropbox\WriteMode::update(null), $fp);
     fclose($fp);
     return $result;
 }
예제 #2
0
 protected static function m($rest, Exception $e = NULL)
 {
     switch (true) {
         case $e instanceof Dropbox\Exception_BadResponseCode:
             switch ($e->getStatusCode()) {
                 case 404:
                     //no file exists: create it!
                     $dir_meta = self::$dbx->getMetadata("/" . dirname($rest));
                     if (is_null($dir_meta) || !$dir_meta["is_dir"]) {
                         self::$dbx->createFolder(dirname($rest));
                     }
                     break;
                 case $e !== NULL:
                     exec(self::GIT . "reset HEAD ../" . $rest);
                     //unstage this file if an exception occurs
                 //unstage this file if an exception occurs
                 case 406:
                     //...
                     return;
                 case 403:
                     //...
                     return;
             }
             break;
         case $e !== NULL:
             exec(self::GIT . "reset HEAD ../" . $rest);
             //unstage this file if an exception occurs
         //unstage this file if an exception occurs
         case $e instanceof Exception_ConflictingRevisions:
             echo "WARNING: File \"" . $rest . "\" was not uploaded due to conflicting revisions. Resolve manually. Continuing...\n";
             //Dropbox has an option to name a "conflicted copy", but this allows us to define the behaviour.
             return;
             //equivalent of continue;
     }
     $f = fopen(SUPER . DIRECTORY_SEPARATOR . $rest, "r");
     $response = self::$dbx->uploadFile(DBX_DIRECTORY_SEPARATOR . $rest, @\Dropbox\WriteMode::update(), $f);
     fclose($f);
     $sql = "UPDATE revs SET rev=\"" . $response["rev"] . "\" WHERE path=" . $rest . " LIMIT 1;";
     mysqli_query(self::$mysqli, $sql);
 }
 public function stream_flush()
 {
     switch ($this->file_mode) {
         case 'r':
         case 'r+':
             return false;
             break;
         case 'a':
         case 'a+':
             $mode = dbx\WriteMode::update();
             break;
         default:
             $mode = dbx\WriteMode::force();
     }
     fseek($this->temp_file_resource, 0);
     $this->Client->uploadFileChunked($this->file_path, $mode, $this->temp_file_resource, null, null);
     return true;
 }