Skip to content

Commit

Permalink
Merge pull request #21008 from owncloud/UoM-ResPlat-DevOps-swift-acl-…
Browse files Browse the repository at this point in the history
…shared-containers

Allowing access to Swift containers shared by ACL
  • Loading branch information
DeepDiver1975 committed Jan 8, 2016
2 parents ea227aa + 8799d55 commit d7d0cfc
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions apps/files_external/lib/swift.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

namespace OC\Files\Storage;

use Guzzle\Http\Url;
use Guzzle\Http\Exception\ClientErrorResponseException;
use Icewind\Streams\IteratorDirectory;
use OpenCloud;
Expand Down Expand Up @@ -123,7 +124,14 @@ public function __construct($params) {
}

$this->id = 'swift::' . $params['user'] . md5($params['bucket']);
$this->bucket = $params['bucket'];

$bucketUrl = Url::factory($params['bucket']);
if ($bucketUrl->isAbsolute()) {
$this->bucket = end(($bucketUrl->getPathSegments()));
$params['endpoint_url'] = $bucketUrl->addPath('..')->normalizePath();
} else {
$this->bucket = $params['bucket'];
}

if (empty($params['url'])) {
$params['url'] = 'https://identity.api.rackspacecloud.com/v2.0/';
Expand Down Expand Up @@ -514,7 +522,16 @@ public function getConnection() {
$this->anchor = new OpenStack($this->params['url'], $settings);
}

$this->connection = $this->anchor->objectStoreService($this->params['service_name'], $this->params['region']);
$connection = $this->anchor->objectStoreService($this->params['service_name'], $this->params['region']);

if (!empty($this->params['endpoint_url'])) {
$endpoint = $connection->getEndpoint();
$endpoint->setPublicUrl($this->params['endpoint_url']);
$endpoint->setPrivateUrl($this->params['endpoint_url']);
$connection->setEndpoint($endpoint);
}

$this->connection = $connection;

return $this->connection;
}
Expand Down

0 comments on commit d7d0cfc

Please sign in to comment.