summaryrefslogtreecommitdiffstats
path: root/apps/files_external/lib/ftp.php
diff options
context:
space:
mode:
authorMichael Gapczynski <mtgap@owncloud.com>2013-02-11 20:27:05 -0500
committerMichael Gapczynski <mtgap@owncloud.com>2013-02-11 20:27:05 -0500
commit6eba790a75ba128e3182771a30dbe88733ee0dfc (patch)
treeba313bec694c64928d82e2b76445d6307a305b22 /apps/files_external/lib/ftp.php
parent6f08b1f829e9d4c49f66b19fdda8c229bc8ae3f3 (diff)
parent04bf8c1b66d6adef0466efae00c32745465767f2 (diff)
downloadnextcloud-server-6eba790a75ba128e3182771a30dbe88733ee0dfc.tar.gz
nextcloud-server-6eba790a75ba128e3182771a30dbe88733ee0dfc.zip
Merge branch 'master' into external_storage_ui_feedback
Conflicts: apps/files_external/js/dropbox.js apps/files_external/js/google.js apps/files_external/js/settings.js apps/files_external/lib/amazons3.php apps/files_external/lib/dropbox.php apps/files_external/lib/google.php apps/files_external/lib/smb.php apps/files_external/lib/swift.php apps/files_external/lib/webdav.php lib/filestorage.php
Diffstat (limited to 'apps/files_external/lib/ftp.php')
-rw-r--r--apps/files_external/lib/ftp.php23
1 files changed, 16 insertions, 7 deletions
diff --git a/apps/files_external/lib/ftp.php b/apps/files_external/lib/ftp.php
index ca408d5d224..a76a3dc80f8 100644
--- a/apps/files_external/lib/ftp.php
+++ b/apps/files_external/lib/ftp.php
@@ -6,7 +6,9 @@
* See the COPYING-README file.
*/
-class OC_FileStorage_FTP extends OC_FileStorage_StreamWrapper{
+namespace OC\Files\Storage;
+
+class FTP extends \OC\Files\Storage\StreamWrapper{
private $password;
private $user;
private $host;
@@ -38,14 +40,18 @@ class OC_FileStorage_FTP extends OC_FileStorage_StreamWrapper{
$this->mkdir('');
}
} else {
- throw new Exception();
+ throw new \Exception();
}
}
+ public function getId(){
+ return 'ftp::' . $this->user . '@' . $this->host . '/' . $this->root;
+ }
+
/**
* construct the ftp url
- * @param string path
+ * @param string $path
* @return string
*/
public function constructUrl($path) {
@@ -56,7 +62,8 @@ class OC_FileStorage_FTP extends OC_FileStorage_StreamWrapper{
$url.='://'.$this->user.':'.$this->password.'@'.$this->host.$this->root.$path;
return $url;
}
- public function fopen($path, $mode) {
+ public function fopen($path,$mode) {
+ $this->init();
switch($mode) {
case 'r':
case 'rb':
@@ -66,7 +73,7 @@ class OC_FileStorage_FTP extends OC_FileStorage_StreamWrapper{
case 'ab':
//these are supported by the wrapper
$context = stream_context_create(array('ftp' => array('overwrite' => true)));
- return fopen($this->constructUrl($path), $mode, false, $context);
+ return fopen($this->constructUrl($path),$mode, false,$context);
case 'r+':
case 'w+':
case 'wb+':
@@ -82,16 +89,18 @@ class OC_FileStorage_FTP extends OC_FileStorage_StreamWrapper{
$ext='';
}
$tmpFile=OCP\Files::tmpFile($ext);
- OC_CloseStreamWrapper::$callBacks[$tmpFile]=array($this, 'writeBack');
+ \OC\Files\Stream\Close::registerCallback($tmpFile, array($this, 'writeBack'));
if ($this->file_exists($path)) {
$this->getFile($path, $tmpFile);
}
self::$tempFiles[$tmpFile]=$path;
- return fopen('close://'.$tmpFile, $mode);
+ return fopen('close://'.$tmpFile,$mode);
}
+ return false;
}
public function writeBack($tmpFile) {
+ $this->init();
if (isset(self::$tempFiles[$tmpFile])) {
$this->uploadFile($tmpFile, self::$tempFiles[$tmpFile]);
unlink($tmpFile);