/** * @return \Aws\Swf\SwfClient */ private function getSwfClient() { $config = json_decode(file_get_contents(ROOT_PATH . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'parameters.json'), true); $awsFactory = Aws::factory(array('credentials' => array('key' => $config['aws_access_key_id'], 'secret' => $config['aws_secret_access_key']), 'region' => $config['aws_region'])); $serviceFactory = new AwsSwfClientProvider($awsFactory); return $serviceFactory->getSwfClient(); }
public function __construct() { $module = \Yii::$app->controller->module; $this->key = isset($module->storage['s3']['key']) ? $module->storage['s3']['key'] : ''; $this->secret = isset($module->storage['s3']['secret']) ? $module->storage['s3']['secret'] : ''; $this->bucket = isset($module->storage['s3']['bucket']) ? $module->storage['s3']['bucket'] : ''; if ($this->key == '') { throw new InvalidConfigException('Key cannot be empty!'); } if ($this->secret == '') { throw new InvalidConfigException('Secret cannot be empty!'); } if ($this->bucket == '') { throw new InvalidConfigException('Bucket cannot be empty!'); } $param = ['key' => $this->key, 'secret' => $this->secret]; if (isset($module->storage['s3']['region'])) { $param['region'] = $module->storage['s3']['region']; } if (isset($module->storage['s3']['proxy'])) { $param['request.options']['proxy'] = $module->storage['s3']['proxy']; } $aws = Aws::factory($param); $this->s3 = $aws->get('S3'); }
function __construct($group_id = "", $region_id = "") { parent::__construct($group_id, $region_id); $this->credentials = new Credentials($this->config['aws_access_key_id'], $this->config['aws_secret_access_key']); $region = $this->region()->getRegion(); $this->AWS = Aws::factory(array('credentials' => $this->credentials, 'region' => $region['id'])); }
public function getAws() { if ($this->_aws === null) { $this->_aws = Aws::factory($this->_config); } return $this->_aws; }
public function updateImageCover() { $sessionToken = $this->input->post('SessionToken'); $accessKeyId = $this->input->post('AccessKeyId'); $secretAccessKey = $this->input->post('SecretAccessKey'); $userId = $this->input->post('userId'); $coverAvatar = $_FILES['CoverFile']['name']; $sourceCover = $_FILES['CoverFile']['tmp_name']; $ext = Myclass::getFileExtension($coverAvatar); $coverAvatar = sha1(time()) . '.' . $ext; $config = array('key' => $accessKeyId, 'secret' => $secretAccessKey, 'token' => $sessionToken); //print_r($config);exit; $aws = Aws::factory($config); $s3AWS = $aws->get('S3'); $bucket = 'superchat-dev'; try { //Create folder and Upload image into S3 Amazon by userId $result = $s3AWS->putObject(array('Bucket' => $bucket, 'Key' => $userId . '/' . $coverAvatar, 'SourceFile' => $sourceCover, 'Body' => "", 'ACL' => 'public-read')); if ($result) { echo '<img src="' . S3_AMAZONE_AWS_SUPERCHAT_DEV . '/' . $userId . '/' . $coverAvatar . '" height="300" id="aws-img-cover">'; } } catch (Exeption $e) { die($e->getMessage()); } }
protected function _init() { if (FALSE === $this->_initialized) { $baseArn = NULL; $apiKey = NULL; $apiSecret = NULL; $region = NULL; if (class_exists('Configure') && NULL !== Configure::constant('AWS_SNS_ARN_BASE')) { $baseArn = Configure::AWS_SNS_ARN_BASE; } if (class_exists('Configure') && NULL !== Configure::constant('AWS_KEY')) { $apiKey = Configure::AWS_KEY; } if (class_exists('Configure') && NULL !== Configure::constant('AWS_SNS_API_KEY')) { $apiKey = Configure::AWS_SNS_API_KEY; } if (class_exists('Configure') && NULL !== Configure::constant('AWS_SECRET')) { $apiSecret = Configure::AWS_SECRET; } if (class_exists('Configure') && NULL !== Configure::constant('AWS_SNS_API_SECRET')) { $apiSecret = Configure::AWS_SNS_API_SECRET; } if (class_exists('Configure') && NULL !== Configure::constant('AWS_REGION')) { $region = Configure::AWS_REGION; } if (class_exists('Configure') && NULL !== Configure::constant('AWS_SNS_REGION')) { $region = Configure::AWS_SNS_REGION; } elseif (defined('PROJECT_NAME') && strlen(PROJECT_NAME) > 0 && class_exists(PROJECT_NAME . 'Configure')) { $ProjectConfigure = PROJECT_NAME . 'Configure'; if (NULL !== $ProjectConfigure::constant('AWS_SNS_ARN_BASE')) { $baseArn = $ProjectConfigure::AWS_SNS_ARN_BASE; } if (NULL !== $ProjectConfigure::constant('AWS_KEY')) { $apiKey = $ProjectConfigure::AWS_KEY; } if (NULL !== $ProjectConfigure::constant('AWS_SNS_API_KEY')) { $apiKey = $ProjectConfigure::AWS_SNS_API_KEY; } if (NULL !== $ProjectConfigure::constant('AWS_SECRET')) { $apiSecret = $ProjectConfigure::AWS_SECRET; } if (NULL !== $ProjectConfigure::constant('AWS_SNS_API_SECRET')) { $apiSecret = $ProjectConfigure::AWS_SNS_API_SECRET; } if (NULL !== $ProjectConfigure::constant('AWS_REGION')) { $region = $ProjectConfigure::AWS_REGION; } if (NULL !== $ProjectConfigure::constant('AWS_SNS_REGION')) { $region = $ProjectConfigure::AWS_SNS_REGION; } } $arns = explode('://', $baseArn); $this->_arnBase = 'arn:aws:sns:' . $arns[0] . ':app/%target_pratform%/' . $arns[1]; $this->_initialized = TRUE; if (NULL === $this->_AWS) { $this->_AWS = Aws::factory(array('key' => $apiKey, 'secret' => $apiSecret, 'region' => Region::TOKYO))->get('sns'); } } }
public function __construct($accessKeyId, $secretAccessKey, $bucket, $region, $host) { $this->bucket = $bucket; $this->host = $host; $this->accesKeyId = $accessKeyId; $this->aws = Aws::factory(array('key' => $accessKeyId, 'secret' => $secretAccessKey, 'region' => $region)); $this->s3 = $this->aws->get('s3'); }
public function __construct($debug) { $this->debug = $debug; // Create AWS SDK instance. // We expect an AWS role or the proper AWS env variable sets for KEY/SECRET $aws = Aws::factory(array('region' => getenv("AWS_DEFAULT_REGION"))); $this->sqs = $aws->get('Sqs'); }
private function createProvidedAws() { $accessKey = $this->app->make('config')->get('laravel-aws-ssh::aws.access_key'); $secretKey = $this->app->make('config')->get('laravel-aws-ssh::aws.secret_key'); $region = $this->app->make('config')->get('laravel-aws-ssh::aws.region', 'us-east-1'); $providedAws = ProvidedAWS::factory(array('key' => $accessKey, 'secret' => $secretKey, 'region' => $region)); return $providedAws; }
/** * */ protected function setUp() { $this->sBucketName = 'your-s3-bucket'; $aConfig = (include self::CONFIG_FILE); $oAWS = Aws::factory($aConfig); $oClient = $oAWS->get('S3'); $this->oService = new AwsS3Service($oClient); }
public function init_s3($access_key, $secret_key, $region = null) { if (!isset($region)) { $region = Region::AP_NORTHEAST_1; } $s3 = Aws::factory(array('key' => $access_key, 'secret' => $secret_key, 'region' => $this->get_region($region)))->get('s3'); $this->s3 = $s3; return $s3; }
function sendMailSES($text, $html, $subject, $from, $to = array()) { try { $client = Aws::factory(getServerRoot() . '/modulos/aws/modelos/configurationFile.php')->get('ses'); $messageId = $client->sendEmail(array('Source' => $from, 'Destination' => array('ToAddresses' => $to), 'Message' => array('Subject' => array('Data' => $subject), 'Body' => array('Text' => array('Data' => $text), 'Html' => array('Data' => $html))))); return true; } catch (Exception $e) { return false; } }
public function init_s3($access_key, $secret_key, $region = null) { if (!isset($region)) { $region = Region::AP_NORTHEAST_1; } $param = array('key' => $access_key, 'secret' => $secret_key, 'region' => $this->get_region($region)); $s3 = Aws::factory(apply_filters('nephila_clavata_credential', $param))->get('s3'); $this->s3 = $s3; return $s3; }
protected function getClient() { if (!$this->client) { $bucket = Config::get('storage.bucket', 'default'); $key = Config::get('storage.key'); $secret = Config::get('storage.secret'); $this->client = Aws::factory(array('bucket' => $bucket, 'key' => $key, 'secret' => $secret))->get('s3'); } return $this->client; }
/** * Register the service provider. * * @return void */ public function register() { $this->app->singleton('aws', function ($app) { $config = $app['config']->get('aws'); if (isset($config['config_file'])) { $config = $config['config_file']; } return Aws::factory($config); }); $this->app->alias('aws', 'Aws\\Common\\Aws'); }
/** * Returns the aws service builder * @return Guzzle\Service\Builder\ServiceBuilder * @throws CException */ public function getAws() { if (null === $this->_aws) { $config = $this->_config !== null ? $this->_config : __DIR__ . '/../config/aws-config.php'; if (is_scalar($config) && !@file_exists($config)) { throw new CException(Yii::t('zii', '"aws-config.php" configuration file not found')); } $this->_aws = Aws::factory($config); } return $this->_aws; }
public function connect() { $config = $this->config; $this->connected = false; try { $this->_connection = Aws::factory($config); $this->connected = true; } catch (Exception $e) { throw new MissingConnectionException(array('class' => get_class($this), 'message' => $e->getMessage())); } return $this->connected; }
function deleteMessageFromQueue($receiptHandle) { $client = Aws::factory(getServerRoot() . '/modulos/aws/modelos/configurationFile.php')->get('sqs'); $res = false; try { $res = $client->deleteMessage(array('QueueUrl' => getQueueUrl(), 'ReceiptHandle' => $receiptHandle)); return true; } catch (SqsException $e) { //OcurriĆ³ un error al borrar el mensaje return false; } }
public function getAwsClientFactory() { // what are we doing? $log = usingLog()->startAction("create AWS client factory using official SDK"); // get the settings for Aws $awsSettings = fromConfig()->getModuleSetting('aws'); // create the AWS client factory $awsFactory = Aws::factory(array('key' => $awsSettings->key, 'secret' => $awsSettings->secret, 'region' => $awsSettings->region)); // all done $log->endAction(); return $awsFactory; }
public function __construct($config, $sesClient = null) { $this->sesClient = $sesClient; if (is_null($this->sesClient)) { $sesConfig = $config->getEmailSesConfig(); if (!isset($sesConfig['aws-access-key']) || !isset($sesConfig['aws-secret-key']) || !isset($sesConfig['region'])) { throw new \Exception('Unable to initiate Emailer due to missing ' . 'configuration variables. Please check your config.'); } $aws = Aws::factory(array('ses' => array('alias' => 'Ses', 'class' => 'Aws\\Ses\\SesClient', 'extends' => 'default_settings'), 'key' => $sesConfig['aws-access-key'], 'secret' => $sesConfig['aws-secret-key'], 'region' => $sesConfig['region']))->enableFacades('ses'); $this->sesClient = $aws->get('ses'); } }
public function __construct($debug, $cpeLogger = null) { $this->debug = $debug; // Create AWS SDK instance $aws = Aws::factory(array('region' => getenv("AWS_DEFAULT_REGION"))); $this->sqs = $aws->get('Sqs'); // Logger if (!$cpeLogger) { $this->cpeLogger = new CpeSdk\CpeLogger(); } else { $this->cpeLogger = $cpeLogger; } }
/** * @param Application $app */ public function boot(Application $app) { $options = $this->options; $app->getDI()->setShared('aws', function () use($options) { $aws = Aws::factory($options); $aws->getEventDispatcher()->addListener('service_builder.create_client', function (Event $event) { $clientConfig = $event['client']->getConfig(); $commandParams = $clientConfig->get(Client::COMMAND_PARAMS) ?: array(); $clientConfig->set(Client::COMMAND_PARAMS, array_merge_recursive($commandParams, array(UserAgentListener::OPTION => 'Phalcon/' . Application::VERSION))); }); return $aws; }); }
/** * @covers \Drupal\amazons3\S3Client::validateBucketExists */ public function testValidateBucketExists() { // Instantiate the AWS service builder. $config = array('includes' => array(0 => '_aws'), 'services' => array('default_settings' => array('params' => array('region' => 'us-east-1')), 'cloudfront' => array('extends' => 'cloudfront', 'params' => array('private_key' => 'change_me', 'key_pair_id' => 'change_me'))), 'credentials' => array('key' => 'placeholder', 'secret' => 'placeholder')); $aws = \Aws\Common\Aws::factory($config); // Configure the tests to use the instantiated AWS service builder \Guzzle\Tests\GuzzleTestCase::setServiceBuilder($aws); $client = $this->getServiceBuilder()->get('s3', true); $this->setMockResponse($client, array(new Response(200))); $exception = NULL; try { DrupalS3Client::validateBucketExists('bucket', $client); } catch (\Exception $exception) { } $this->assertNull($exception, 'The bucket was validated to exist.'); }
/** * connect */ public function connect($uri, $options = array()) { list($region) = explode('/', $uri); if (is_null($region) || strlen($region) == 0) { throw new \mychaelstyle\Exception('Fail to connect aws! option \'region\' is required!', \mychaelstyle\Exception::ERROR_PROVIDER_CONNECTION); } $defRegion = @constant('Aws\\Common\\Enum\\Region::' . $region); $this->region = is_null($defRegion) ? $region : $defRegion; $options['region'] = $this->region; try { $aws = \Aws\Common\Aws::factory($options); $this->client = $aws->get($this->getServiceName()); } catch (\Exception $e) { throw new \mychaelstyle\Exception('Fail to connect aws!', \mychaelstyle\Exception::ERROR_PROVIDER_CONNECTION, $e); } }
/** * @param string $group configuration group to be used. * @param string $global_params */ public static function factory($group = null, array $global_params = array()) { if (empty($group)) { $group = self::$_config_group; } if (is_string($group)) { $config = Kohana::$config->load(self::DEFAULT_CONFIG_PATH)->as_array(); // load configuration from kohana config file. if (empty($config[$group])) { throw new Kohana_Exception('Cannot find :class configuration group `:group` on file `:file`', array(':class' => __CLASS__, ':group' => $group, ':file' => self::DEFAULT_CONFIG_PATH)); return false; } $group = $config[$group]; } return parent::factory($group, $config); }
/** * test case startup * * @return void */ public static function setupBeforeClass() { self::$_sessionBackup = Configure::read('Session'); // Connection to DynamoDB Local $aws = Aws::factory(array('key' => 'XXXXXXXXXXXXXX', 'secret' => 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyy', 'region' => 'us-east-1', 'base_url' => 'http://localhost:8000')); Configure::write('Session.handler', array('engine' => 'AwsUtils.DynamoDBSession', 'aws' => $aws)); Configure::write('Session.timeout', 100); $dynamoDB = $aws->get('dynamodb'); $found = false; $response = $dynamoDB->listTables(array()); if (!in_array(DynamoDBSession::DEFAULT_TABLE_NAME, $response['TableNames'])) { $handler = new DynamoDBSession(); $aws_handler = $handler->getSessionHandler(); $aws_handler->createSessionsTable(5, 5); } }
function getAWSService($region, $accprov) { $providerArray = json_decode($this->getAppContext()->getCloudproviders()); $awsacesskey = $providerArray->{$accprov}->accessKey; $secretkey = $providerArray->{$accprov}->secretKey; try { loghandler(DEBUG, "Creating service factory"); //echo "\ncreating service factory ....................:"; $aws = Aws::factory(array('key' => $awsacesskey, 'secret' => $secretkey, 'region' => $region)); loghandler(DEBUG, "Got service factory"); return $aws; } catch (Exception $se) { $message = $se->getMessage(); trigger_error($message, E_USER_ERROR); } return null; }
function __construct($key = false, $secret = false, $region = false, $debug = false) { if (!$key && !($key = getenv("AWS_ACCESS_KEY_ID"))) { throw new \Exception("Set 'AWS_ACCESS_KEY_ID' environment variable!"); } if (!$secret && !($secret = getenv("AWS_SECRET_KEY"))) { throw new \Exception("Set 'AWS_SECRET_KEY' environment variable!"); } if (!$region && !($region = getenv("AWS_DEFAULT_REGION"))) { throw new \Exception("Set 'AWS_DEFAULT_REGION' environment variable!"); } $this->region = $region; $this->debug = $debug; // Create AWS SDK instance $this->aws = Aws::factory(array('region' => $region)); $this->sts = $this->aws->get('Sts'); $this->sqs = $this->aws->get('Sqs'); }
public function __construct($bucket, $credentialsFile, $folder = '') { $this->configPath = $_SERVER['DOCUMENT_ROOT'] . $this->configPath; $configFile = $this->configPath . $credentialsFile; if (!file_exists($configFile)) { return $this->error("credentials not found"); } $this->bucket = $bucket; if ($folder && substr($folder, -1) != '/') { // folder may be an empty string, but if given, it shuold end on a / or we are NOT checking on a folder but instead on a file prefix (which may also include a path). in this case we only look for folders, therefore: $folder .= '/'; } elseif ($folder && substr($folder, -2) == '//') { // folder may be an empty string, but if given, it shuold end on a / or we are NOT checking on a folder but instead on a file prefix (which may also include a path). in this case we only look for folders, therefore: return $this->error("video id missing"); } $this->folder = $folder; $this->client = Aws::factory($configFile)->get('S3'); }
public function execute() { // Check options $options = $this->getOptions(); $this->origin_config_path = $options['config']->value; $this->output_config_path = $options['output']->value; if (empty($this->origin_config_path)) { throw new Exception('The <config> option is required'); } if (empty($this->output_config_path)) { throw new Exception('The <output> option is required'); } // Module config $config = (include $this->origin_config_path); // Check deply config if (empty($config['deploy'])) { throw new Exception("You haven't defined the deploy setting in config file."); } // S3 Instance $this->s3_setting = $config['deploy']; $s3config = array('key' => $this->s3_setting['key'], 'secret' => $this->s3_setting['secret']); try { $this->s3 = Aws::factory($s3config)->get('s3'); } catch (S3Exception $e) { $this->logger->error($e->message); } // Module config $config = (include $this->origin_config_path); $modules = $config['modules']; $this->assetla = new Assetla($this->origin_config_path); foreach ($modules as $name => $types) { foreach ($types as $type => $files) { $url = $this->iterate($name, $type); $this->logger->info("Generated asset: {$url}"); $config['modules'][$name][$type] = array($url); } } // Generate config $content = var_export($config, TRUE); $content = "<?php\nreturn {$content};\n"; file_put_contents($this->output_config_path, $content); $this->logger->info("Generated config: {$this->output_config_path}"); }