implement getId for the external storage providers

This commit is contained in:
Robin Appelman 2012-10-11 23:06:57 +02:00
parent fb2d2bc201
commit 542869114a
7 changed files with 37 additions and 1 deletions

View File

@ -29,12 +29,14 @@ class AmazonS3 extends \OC\Files\Storage\Common {
private $s3;
private $bucket;
private $objects = array();
private $id;
private static $tempFiles = array();
// TODO options: storage class, encryption server side, encrypt before upload?
public function __construct($params) {
$this->id = 'amazon::'.$params['key'] . md5($params['secret']);
$this->s3 = new \AmazonS3(array('key' => $params['key'], 'secret' => $params['secret']));
$this->bucket = $params['bucket'];
}
@ -59,6 +61,10 @@ class AmazonS3 extends \OC\Files\Storage\Common {
return false;
}
public function getId(){
return $this->id;
}
public function mkdir($path) {
// Folders in Amazon S3 are 0 byte objects with a '/' at the end of the name
if (substr($path, -1) != '/') {

View File

@ -28,12 +28,14 @@ class Dropbox extends \OC\Files\Storage\Common {
private $dropbox;
private $root;
private $id;
private $metaData = array();
private static $tempFiles = array();
public function __construct($params) {
if (isset($params['configured']) && $params['configured'] == 'true' && isset($params['app_key']) && isset($params['app_secret']) && isset($params['token']) && isset($params['token_secret'])) {
$this->id = 'dropbox::'.$params['app_key'] . $params['token']. '/' . $params['root'];
$this->root=isset($params['root'])?$params['root']:'';
$oauth = new \Dropbox_OAuth_Curl($params['app_key'], $params['app_secret']);
$oauth->setToken($params['token'], $params['token_secret']);
@ -81,6 +83,10 @@ class Dropbox extends \OC\Files\Storage\Common {
}
}
public function getId(){
return $this->id;
}
public function mkdir($path) {
$path = $this->root.$path;
try {

View File

@ -32,6 +32,10 @@ class FTP extends \OC\Files\Storage\StreamWrapper{
}
}
public function getId(){
return 'ftp::' . $this->user . '@' . $this->host . '/' . $this->root;
}
/**
* construct the ftp url
* @param string path

View File

@ -30,6 +30,7 @@ class Google extends \OC\Files\Storage\Common {
private $oauth_token;
private $sig_method;
private $entries;
private $id;
private static $tempFiles = array();
@ -37,6 +38,7 @@ class Google extends \OC\Files\Storage\Common {
if (isset($params['configured']) && $params['configured'] == 'true' && isset($params['token']) && isset($params['token_secret'])) {
$consumer_key = isset($params['consumer_key']) ? $params['consumer_key'] : 'anonymous';
$consumer_secret = isset($params['consumer_secret']) ? $params['consumer_secret'] : 'anonymous';
$this->id = 'google::' . $consumer_key . $consumer_secret;
$this->consumer = new \OAuthConsumer($consumer_key, $consumer_secret);
$this->oauth_token = new \OAuthToken($params['token'], $params['token_secret']);
$this->sig_method = new \OAuthSignatureMethod_HMAC_SHA1();
@ -177,6 +179,9 @@ class Google extends \OC\Files\Storage\Common {
}
}
public function getId(){
return $this->id;
}
public function mkdir($path) {
$collection = dirname($path);
@ -539,4 +544,4 @@ class Google extends \OC\Files\Storage\Common {
}
}
}

View File

@ -42,6 +42,10 @@ class SMB extends \OC\Files\Storage\StreamWrapper{
}
}
public function getId(){
return 'smb::' . $this->user . '@' . $this->host . '/' . $this->share . '/' . $this->root;
}
public function constructUrl($path) {
if(substr($path,-1)=='/') {
$path=substr($path,0,-1);

View File

@ -11,6 +11,7 @@ require_once 'php-cloudfiles/cloudfiles.php';
namespace OC\Files\Storage;
class SWIFT extends \OC\Files\Storage\Common{
private $id;
private $host;
private $root;
private $user;
@ -274,6 +275,8 @@ class SWIFT extends \OC\Files\Storage\Common{
$this->user=$params['user'];
$this->root=isset($params['root'])?$params['root']:'/';
$this->secure=isset($params['secure'])?(bool)$params['secure']:true;
$this->id = 'swift::' . $this->user . '@' . $this->host . '/' . $this->root;
if(!$this->root || $this->root[0]!='/') {
$this->root='/'.$this->root;
}
@ -289,6 +292,10 @@ class SWIFT extends \OC\Files\Storage\Common{
}
}
public function getId(){
return $this->id;
}
public function mkdir($path) {
if($this->containerExists($path)) {

View File

@ -56,6 +56,10 @@ class DAV extends \OC\Files\Storage\Common{
$this->mkdir('');
}
public function getId(){
return 'webdav::' . $this->user . '@' . $this->host . '/' . $this->root;
}
private function createBaseUri() {
$baseUri='http';
if($this->secure) {