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

Commit

Permalink
Browse files Browse the repository at this point in the history
[access.s3] Adding SDKv3 compatibility
  • Loading branch information
isma91 committed Feb 17, 2016
1 parent bd12f3e commit 53f4ae9
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions core/src/plugins/access.s3/class.s3AccessDriver.php
Expand Up @@ -19,11 +19,9 @@
* The latest code can be found at <http://pyd.io/>.
*
*/

defined('AJXP_EXEC') or die( 'Access not allowed');
use Aws\S3\S3Client;
use Guzzle\Plugin\Log\LogPlugin;

use AccessS3\S3Client;
/**
* AJXP_Plugin to access a webdav enabled server
* @package AjaXplorer_Plugins
Expand Down Expand Up @@ -56,9 +54,10 @@ public function detectStreamWrapper($register = false){

if(isSet($this->repository)){
require_once("aws.phar");
require_once __DIR__ . DIRECTORY_SEPARATOR . 'class.pydioS3Client.php';
$options = array(
'key' => $this->repository->getOption("API_KEY"),
'secret' => $this->repository->getOption("SECRET_KEY")
'secret' => $this->repository->getOption("SECRET_KEY"),
);
$signatureVersion = $this->repository->getOption("SIGNATURE_VERSION");
if(!empty($signatureVersion) && $signatureVersion != "-1"){
Expand All @@ -76,13 +75,26 @@ public function detectStreamWrapper($register = false){
if(!empty($proxy)){
$options['request.options'] = array('proxy' => $proxy);
}
$this->s3Client = S3Client::factory($options);

if($this->repository->getOption("VHOST_NOT_SUPPORTED")){
// Use virtual hosted buckets when possible
require_once("ForcePathStyleListener.php");
$this->s3Client->addSubscriber(new \Aws\S3\ForcePathStyleStyleListener());
$apiVersion = $this->repository->getOption("API_VERSION");
if ($apiVersion === "") {
$apiVersion = "latest";
}
$sdkVersion = $this->getFilteredOption("SDK_VERSION");
if ($sdkVersion === "v3") {
$this->s3Client = new S3Client([
"version" => $apiVersion,
"region" => $region,
"credentials" => $options
]);
} else {
$this->s3Client = S3Client::factory($options);
if($this->repository->getOption("VHOST_NOT_SUPPORTED")){
// Use virtual hosted buckets when possible
require_once("ForcePathStyleListener.php");
$this->s3Client->addSubscriber(new \Aws\S3\ForcePathStyleStyleListener());
}
}


$this->s3Client->registerStreamWrapper();
}
Expand Down

0 comments on commit 53f4ae9

Please sign in to comment.