コード例 #1
0
ファイル: AswS3.php プロジェクト: kinfosoft/yii2-aws-s3-sdk
 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;
     }
 }
コード例 #2
0
 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'));
 }
コード例 #3
0
ファイル: Aws.php プロジェクト: websharks/core
 /**
  * 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>
 }
コード例 #4
0
ファイル: Version3Layer.php プロジェクト: silktide/stash
 protected function load()
 {
     if (!$this->s3Client) {
         $this->s3Client = DependencyRegistry::load("S3V2", function () {
             $sdk = new Sdk(["region" => "us-east-1", "version" => "latest"]);
             return $sdk->createS3();
         });
     }
 }
コード例 #5
0
 public function __construct(\Aws\Sdk $sdk)
 {
     $this->asg = $sdk->createAutoScaling();
 }
コード例 #6
0
 /**
  * @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));
 }
コード例 #7
0
ファイル: _ide_helper.php プロジェクト: antriver/ctrlv-api
 /**
  * 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);
 }
コード例 #8
0
 /**
  * Create aws service clients
  * @param $serviceType
  * @return mixed
  */
 public function createAwsServiceClient($serviceType)
 {
     return $this->sdk->createClient($serviceType);
 }
コード例 #9
0
 /**
  * New DynamoDb Client
  * 
  * @return \Aws\DynamoDb\DynamoDbClient
  */
 public function newConnection()
 {
     $this->connections[] = $this->sdk->createDynamoDb();
     return last($this->connections);
 }
コード例 #10
0
 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);
 }
コード例 #11
0
ファイル: DynamoDb.php プロジェクト: jacksteadman/tracer2
 function __construct(Sdk $sdk)
 {
     $this->client = $sdk->createClient('DynamoDb');
     $this->marshaler = new Marshaler();
 }
コード例 #12
0
 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();
 }