public static function deleteBucket($app) { $user_storage_s3 = Doctrine::getTable('GcrUserStorageS3')->findOneByAppId($app->getShortName()); if ($user_storage_s3) { $account = GcrUserStorageS3Table::getAccount($app); define('AWS_KEY', $account->getAccessKeyId()); define('AWS_SECRET_KEY', $account->getSecretAccessKey()); gcr::loadSdk('aws'); $api = new AmazonS3(); $api->delete_bucket($user_storage_s3->getBucketName(), true); $user_storage_s3->delete(); } }
/** * Constructor * @param int $repositoryid * @param object $context * @param array $options */ public function __construct($repositoryid, $context = SYSCONTEXTID, $options = array()) { parent::__construct($repositoryid, $context, $options); // OVERWRITE 1: replacement // changed from // $this->access_key = get_config('s3', 'access_key'); // $this->secret_key = get_config('s3', 'secret_key'); // To: global $CFG; $account = GcrUserStorageS3Table::getAccount($CFG->current_app->getInstitution()); $this->access_key = $account->getAccessKeyId(); $this->secret_key = $account->getSecretAccessKey(); // END OVERWRITE 1 $this->s = new S3($this->access_key, $this->secret_key); $this->s->setExceptions(true); }
public function __construct($app = false) { $this->app = $app; if (!$app) { global $CFG; $this->app = $CFG->current_app; } $account = GcrUserStorageS3Table::getAccount($this->app); define('AWS_KEY', $account->getAccessKeyId()); define('AWS_SECRET_KEY', $account->getSecretAccessKey()); gcr::loadSdk('aws'); $this->api = new AmazonS3(); if (!($user_storage_s3 = Doctrine::getTable('GcrUserStorageS3')->findOneByAppId($this->app->getInstitution()->getShortName()))) { $user_storage_s3 = $this->createBucket($account); } else { $this->bucket = $user_storage_s3->getBucketName(); } }