Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Fix S3 driver to load underlying wrappers during detectStreamWrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
cdujeu committed Oct 27, 2014
1 parent e142570 commit e8aa555
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 15 deletions.
42 changes: 27 additions & 15 deletions core/src/plugins/access.s3/class.s3AccessDriver.php
Expand Up @@ -47,23 +47,36 @@ public function performChecks()
if(!file_exists($this->getBaseDir()."/aws.phar")) throw new Exception("Cannot find AWS PHP SDK v2. Make sure the aws.phar package is installed inside access.s3 plugin.");
}

/**
* @param bool $register
* @return array|bool|void
* Override parent to register underlying wrapper (s3) as well
*/
public function detectStreamWrapper($register = false){

if(isSet($this->repository)){
require_once("aws.phar");
$options = array(
'key' => $this->repository->getOption("API_KEY"),
'secret' => $this->repository->getOption("SECRET_KEY")
);
$baseURL = $this->repository->getOption("STORAGE_URL");
if(!empty($baseURL)){
$options["base_url"] = $baseURL;
}else{
$options["region"] = $this->repository->getOption("REGION");
}
$this->s3Client = S3Client::factory($options);
$this->s3Client->registerStreamWrapper();
//$this->s3Client->addSubscriber(LogPlugin::getDebugPlugin());
}

return parent::detectStreamWrapper($register);
}

public function initRepository()
{
require_once("aws.phar");
$options = array(
'key' => $this->repository->getOption("API_KEY"),
'secret' => $this->repository->getOption("SECRET_KEY")
);
$baseURL = $this->repository->getOption("STORAGE_URL");
if(!empty($baseURL)){
$options["base_url"] = $baseURL;
}else{
$options["region"] = $this->repository->getOption("REGION");
}
$this->s3Client = S3Client::factory($options);
$this->s3Client->registerStreamWrapper();
//$this->s3Client->addSubscriber(LogPlugin::getDebugPlugin());
$wrapperData = $this->detectStreamWrapper(true);

if (is_array($this->pluginConf)) {
$this->driverConf = $this->pluginConf;
Expand All @@ -73,7 +86,6 @@ public function initRepository()

$recycle = $this->repository->getOption("RECYCLE_BIN");
ConfService::setConf("PROBE_REAL_SIZE", false);
$wrapperData = $this->detectStreamWrapper(true);
$this->wrapperClassName = $wrapperData["classname"];
$this->urlBase = $wrapperData["protocol"]."://".$this->repository->getId();
if ($recycle != "") {
Expand Down
Expand Up @@ -124,6 +124,7 @@ public function crossRepositoryCopy($httpVars)
$destRepoObject = ConfService::getRepositoryById($destRepoId);
$destRepoAccess = $destRepoObject->getAccessType();
$plugin = AJXP_PluginsService::findPlugin("access", $destRepoAccess);
$plugin->repository = $destRepoObject;
$destWrapperData = $plugin->detectStreamWrapper(true);
$destStreamURL = $destWrapperData["protocol"]."://$destRepoId";
// Check rights
Expand Down

0 comments on commit e8aa555

Please sign in to comment.