diff --git a/core/src/plugins/access.s3/class.s3AccessDriver.php b/core/src/plugins/access.s3/class.s3AccessDriver.php index c92ea83e4a..4f72c76a6f 100755 --- a/core/src/plugins/access.s3/class.s3AccessDriver.php +++ b/core/src/plugins/access.s3/class.s3AccessDriver.php @@ -66,6 +66,10 @@ public function detectStreamWrapper($register = false){ }else{ $options["region"] = $this->repository->getOption("REGION"); } + $proxy = $this->repository->getOption("PROXY"); + if(!empty($proxy)){ + $options['request.options'] = array('proxy' => $proxy); + } $this->s3Client = S3Client::factory($options); $this->s3Client->registerStreamWrapper(); } @@ -86,6 +90,16 @@ public function initRepository() ConfService::setConf("PROBE_REAL_SIZE", false); $this->wrapperClassName = $wrapperData["classname"]; $this->urlBase = $wrapperData["protocol"]."://".$this->repository->getId(); + + if ($recycle!= "" && !is_dir($this->urlBase. "/" . $recycle . "/")) { + @mkdir($this->urlBase. "/" . $recycle . "/", 0777, true); + if(!is_dir($this->urlBase. "/" . $recycle . "/")) { + throw new AJXP_Exception("Cannot create recycle bin folder. Please check repository configuration or that your folder is writeable!"); + } else { + $this->setHiddenAttribute(new AJXP_Node($this->urlBase. "/" . $recycle . "/")); + } + } + if ($recycle != "") { RecycleBinManager::init($this->urlBase, "/".$recycle); } diff --git a/core/src/plugins/access.s3/class.s3AccessWrapper.php b/core/src/plugins/access.s3/class.s3AccessWrapper.php index 4a5e900942..e1eda047c4 100755 --- a/core/src/plugins/access.s3/class.s3AccessWrapper.php +++ b/core/src/plugins/access.s3/class.s3AccessWrapper.php @@ -192,7 +192,21 @@ public static function copyFileInStream($path, $stream) public static function changeMode($path, $chmodValue){} public function rename($from, $to){ - if(is_dir($from)){ + + $fromUrl = parse_url($from); + $repoId = $fromUrl["host"]; + $repoObject = ConfService::getRepositoryById($repoId); + $isViPR = $repoObject->getOption("IS_VIPR"); + $isDir = false; + if($isViPR === true) { + if(is_dir($from . "/")) { + $from .= '/'; + $to .= '/'; + $isDir = true; + } + } + + if($isDir === true || is_dir($from)){ AJXP_Logger::debug(__CLASS__, __FUNCTION__, "S3 Renaming dir $from to $to"); require_once("aws.phar"); @@ -215,12 +229,24 @@ public function rename($from, $to){ }else{ $options["region"] = $repoObject->getOption("REGION"); } + $proxy = $repoObject->getOption("PROXY"); + if(!empty($proxy)){ + $options['request.options'] = array('proxy' => $proxy); + } $s3Client = S3Client::factory($options); $bucket = $repoObject->getOption("CONTAINER"); $basePath = $repoObject->getOption("PATH"); $fromKeyname = trim(str_replace("//", "/", $basePath.parse_url($from, PHP_URL_PATH)),'/'); $toKeyname = trim(str_replace("//", "/", $basePath.parse_url($to, PHP_URL_PATH)), '/'); + if($isViPR) { + $toKeyname .= '/'; + $parts = explode('/', $bucket); + $bucket = $parts[0]; + if(isset($parts[1])) { + $fromKeyname = $parts[1] . "/" . $fromKeyname; + } + } // Perform a batch of CopyObject operations. $batch = array(); @@ -234,6 +260,11 @@ public function rename($from, $to){ $currentFrom = $object['Key']; $currentTo = $toKeyname.substr($currentFrom, strlen($fromKeyname)); + if($isViPR) { + if(isset($parts[1])) { + $currentTo = $parts[1] . "/" . $currentTo; + } + } AJXP_Logger::debug(__CLASS__, __FUNCTION__, "S3 Should move one object ".$currentFrom. " to new key :".$currentTo); $batch[] = $s3Client->getCommand('CopyObject', array( 'Bucket' => $bucket, diff --git a/core/src/plugins/access.s3/manifest.xml b/core/src/plugins/access.s3/manifest.xml index e0379177d0..4e270f765d 100755 --- a/core/src/plugins/access.s3/manifest.xml +++ b/core/src/plugins/access.s3/manifest.xml @@ -13,6 +13,8 @@ + +