public function uploadObject($source, $bucket, $key, $acl = self::ACL_PRIVATE) { $this->source = $source; $this->bucket = $bucket; $this->key = $key; $this->acl = $acl; $this->scenario = 'put'; if ($this->validate()) { $sdk = new Sdk(['version' => 'latest', 'region' => Yii::$app->params['amazon']['region'], 'credentials' => Yii::$app->params['amazon']['credentials']]); $s3 = $sdk->createS3(); $file = null; try { $file = fopen($this->source, 'r'); $result = $s3->upload($this->bucket, $this->key, $file, $this->acl, ['Content-Type' => $this->getContentType()]); return $result->get('ObjectURL'); } catch (\Exception $e) { Yii::error('Error uploading files to S3. ' . $e->getMessage()); } if ($file != null) { fclose($file); } return false; } else { return false; } }
public function connection() { $sdk = new Sdk(['region' => 'us-west-2', 'version' => 'latest', 'endpoint' => 'http://localhost:8000', 'credentials' => false]); $dynamodb = $sdk->createDynamoDb(); $tableName = 'users'; $result = $dynamodb->createTable(['TableName' => $tableName, 'AttributeDefinitions' => [['AttributeName' => 'Id', 'AttributeType' => 'N']], 'KeySchema' => [['AttributeName' => 'Id', 'KeyType' => 'HASH']], 'ProvisionedThroughput' => ['ReadCapacityUnits' => 5, 'WriteCapacityUnits' => 6]]); print_r($result->getPath('TableDescription')); }
/** * Constructor. * * @since 160719 Initial release. * * @param Classes\App $App Instance of App. */ public function __construct(Classes\App $App) { parent::__construct($App); $this->Sdk = new AwsLib\Sdk(['version' => 'latest', 'region' => $this->App->Config->©aws['©region'], 'credentials' => ['key' => $this->App->Config->©aws['©access_key'], 'secret' => $this->App->Config->©aws['©secret_key']]]); $this->S3Client = $this->Sdk->createS3(['version' => $this->App->Config->©aws['©s3_version']]); // A quick example of how this can be used in PHP. // $this->S3Client->registerStreamWrapper(); // See: <http://docs.aws.amazon.com/aws-sdk-php/v3/guide/service/s3-stream-wrapper.html> }
protected function load() { if (!$this->s3Client) { $this->s3Client = DependencyRegistry::load("S3V2", function () { $sdk = new Sdk(["region" => "us-east-1", "version" => "latest"]); return $sdk->createS3(); }); } }
public function __construct(\Aws\Sdk $sdk) { $this->asg = $sdk->createAutoScaling(); }
/** * @param AWSCredentials $AWSCredentials * @param $service * * @throws \InvalidArgumentException * * @return mixed */ public function get(AWSCredentials $AWSCredentials, $service) { $aws = new Aws($AWSCredentials->getParameters()); return $aws->createClient($service, $AWSCredentials->getParameters($service)); }
/** * Determine the endpoint prefix from a client namespace. * * @param string $name Namespace name * @return string * @internal * @deprecated Use the `\Aws\manifest()` function instead. * @static */ public static function getEndpointPrefix($name) { return \Aws\Sdk::getEndpointPrefix($name); }
/** * Create aws service clients * @param $serviceType * @return mixed */ public function createAwsServiceClient($serviceType) { return $this->sdk->createClient($serviceType); }
/** * New DynamoDb Client * * @return \Aws\DynamoDb\DynamoDbClient */ public function newConnection() { $this->connections[] = $this->sdk->createDynamoDb(); return last($this->connections); }
protected function getClientFromConfig($config) { $awsConfig = ['credentials' => ['key' => $config['key'], 'secret' => $config['secret']], 'region' => $config['region'], 'version' => $config['version']]; $sdk = new Sdk(); return $sdk->createClient($config['name'], $awsConfig); }
function __construct(Sdk $sdk) { $this->client = $sdk->createClient('DynamoDb'); $this->marshaler = new Marshaler(); }
public function __construct() { $sdk = new Sdk(['version' => 'latest', 'debug' => false, 'retries' => 3, 'credentials' => ['key' => CustomCredentials::SNS_KEY, 'secret' => CustomCredentials::SNS_SECRET], 'Sns' => ['region' => 'sa-east-1']]); $this->sns = $sdk->createSns(); $this->generatePlatformApplicationArn(); }