本文整理汇总了PHP中Aws\S3\S3Client::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP S3Client::factory方法的具体用法?PHP S3Client::factory怎么用?PHP S3Client::factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Aws\S3\S3Client
的用法示例。
在下文中一共展示了S3Client::factory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: do_activity
public function do_activity($task)
{
parent::do_activity($task);
// Use workflowID to generate a unique TMP folder localy.
$this->tmpPathInput = self::TMP_FOLDER . $task["workflowExecution"]["workflowId"] . "/" . "input";
$inputFileInfo = null;
// Create TMP storage to store input file to transcode
if (isset($this->input->{'input_asset'}->{'file'})) {
$inputFileInfo = pathinfo($this->input->{'input_asset'}->{'file'});
}
// Create the tmp folder if doesn't exist
if (!file_exists($this->tmpPathInput)) {
if ($this->debug) {
$this->cpeLogger->log_out("INFO", basename(__FILE__), "Creating TMP input folder '" . $this->tmpPathInput . "'", $this->activityLogKey);
}
if (!mkdir($this->tmpPathInput, 0750, true)) {
throw new CpeSdk\CpeException("Unable to create temporary folder '{$this->tmpPathInput}' !", self::TMP_FOLDER_FAIL);
}
}
$this->pathToInputFile = null;
if (isset($this->input->{'input_asset'}->{'bucket'}) && isset($this->input->{'input_asset'}->{'file'})) {
// Make pre-signed URL so ffmpeg has access to file
$this->pathToInputFile = 'cache:' . S3Client::factory()->getCommand('GetObject', ['Bucket' => $this->input->{'input_asset'}->{'bucket'}, 'Key' => $this->input->{'input_asset'}->{'file'}])->createPresignedUrl('+1 day');
} else {
if ($this->input->{'input_asset'}->{'http'}) {
// Pad HTTP input so it is cached in case of full encodes
$this->pathToInputFile = 'cache:' . $this->input->{'input_asset'}->{'http'};
}
}
}
示例2: make
/**
* @param string $name
* @return \League\Flysystem\AdapterInterface
* @throws \RuntimeException
*/
public static function make($name)
{
$connections = Config::get('storage.connections');
if (!isset($connections[$name])) {
throw new \RuntimeException(sprintf('The storage connection %d does not exist.', $name));
}
$connection = $connections[$name];
$connection['adapter'] = strtoupper($connection['adapter']);
switch ($connection['adapter']) {
case 'LOCAL':
return new Local($connection['root_path'], $connection['public_url_base']);
case 'RACKSPACE':
$service = isset($connection['service']) ? Config::get($connection['service']) : Config::get('services.rackspace');
$client = new Rackspace($service['api_endpoint'], array('username' => $service['username'], 'tenantName' => $service['tenant_name'], 'apiKey' => $service['api_key']));
$store = $client->objectStoreService($connection['store'], $connection['region']);
$container = $store->getContainer($connection['container']);
return new RackspaceAdapter($container);
case 'AWS':
$service = isset($connection['service']) ? Config::get($connection['service']) : Config::get('services.aws');
$client = S3Client::factory(array('credentials' => array('key' => $service['access_key'], 'secret' => $service['secret_key']), 'region' => $service['region'], 'version' => 'latest'));
return new AwsS3Adapter($client, $connection['bucket']);
case 'GCLOUD':
$service = isset($connection['service']) ? Config::get($connection['service']) : Config::get('services.google_cloud');
$credentials = new \Google_Auth_AssertionCredentials($service['service_account'], [\Google_Service_Storage::DEVSTORAGE_FULL_CONTROL], file_get_contents($service['key_file']), $service['secret']);
$config = new \Google_Config();
$config->setAuthClass(GoogleAuthOAuth2::class);
$client = new \Google_Client($config);
$client->setAssertionCredentials($credentials);
$client->setDeveloperKey($service['developer_key']);
$service = new \Google_Service_Storage($client);
return new GoogleStorageAdapter($service, $connection['bucket']);
}
throw new \RuntimeException(sprintf('The storage adapter %s is invalid.', $connection['adapter']));
}
示例3: __construct
protected function __construct($attrs = null)
{
if (!$this->no_backend) {
if (!$this->table) {
$this->table = strtolower(Inflector::get()->pluralize(get_class($this)));
}
$this->db = DB::instance();
}
if (!$this->no_cache) {
$this->cache = Cache::instance();
}
if (class_exists('\\Notifier')) {
$this->notifier = \Notifier::instance();
}
if (defined('AWS_CONSUMER_KEY') && defined('AWS_CONSUMER_SECRET') && defined('AWS_BUCKET')) {
if (!class_exists('\\Aws\\S3\\S3Client')) {
throw new Exception("AWS S3 packaged is required");
}
$this->s3 = \Aws\S3\S3Client::factory(array('key' => AWS_CONSUMER_KEY, 'secret' => AWS_CONSUMER_SECRET));
}
$this->validator = ValidatorBase::instance();
if ($attrs && is_numeric($attrs)) {
// assume $attrs is id
$this->findOne(array($this->primary_key => $attrs));
} else {
if ($attrs && is_array($attrs)) {
if (!array_key_exists($this->primary_key, $attrs)) {
$this->validate($attrs);
}
// set the attrs
$this->attrs = $attrs;
$this->protectAttrs();
}
}
}
示例4: getS3Client
private function getS3Client()
{
if (!$this->s3Client) {
$this->s3Client = S3Client::factory(array('key' => $this->awsAccessKey, 'secret' => $this->awsAccessSecret));
}
return $this->s3Client;
}
示例5: __construct
public function __construct($key, $secret)
{
$this->key = $key;
$this->secret = $secret;
$arr = array('key' => $key, 'secret' => $secret, 'region' => AWS_REGION);
$this->s3 = S3Client::factory($arr);
}
示例6: __construct
/**
* @inheritdoc
* @param array $values
*/
public function __construct(array $values = [])
{
$values['amazon_s3_client'] = $this->share(function (Application $app) {
return S3Client::factory(array_merge($this->getCredentials(), ['version' => '2006-03-01', 'ssl.certificate_authority' => false]));
});
$values['amazon_s3_credentials_cookie_name'] = 'credentials';
$values['controller.amazon_s3_client'] = $this->share(function (Application $app) {
return new AmazonS3Controller($app['twig'], $app['amazon_s3_client']);
});
$values['controller.authentication'] = $this->share(function (Application $app) {
return new AuthenticationController($app['twig'], $app['amazon_s3_credentials_cookie_name']);
});
parent::__construct($values);
$this->register(new TwigServiceProvider(), ['twig.path' => __DIR__ . '/../views', 'twig.options' => ['cache' => is_writable(__DIR__ . '/..') ? __DIR__ . '/../cache/twig' : false]]);
$this->register(new UrlGeneratorServiceProvider());
$this->register(new ServiceControllerServiceProvider());
$this->get('/login', 'controller.authentication:loginAction')->bind('login')->before(function (Request $request, Application $app) {
$credentials = $this->getCredentials();
if (!empty($credentials)) {
return new RedirectResponse($app['url_generator']->generate('list'));
}
});
$this->post('/login', 'controller.authentication:authenticateAction');
$this->post('/logout', 'controller.authentication:logoutAction')->bind('logout');
$this->get('/{bucket}', 'controller.amazon_s3_client:listAction')->value('bucket', null)->bind('list')->before(function (Request $request, Application $app) {
$credentials = $this->getCredentials();
if (empty($credentials)) {
return $app->handle(Request::create($app['url_generator']->generate('login')), HttpKernelInterface::SUB_REQUEST, false);
}
});
}
示例7: __construct
public function __construct($params)
{
if (!isset($params['key']) || !isset($params['secret']) || !isset($params['bucket'])) {
throw new \Exception("Access Key, Secret and Bucket have to be configured.");
}
$this->id = 'amazon::' . $params['key'] . md5($params['secret']);
$this->bucket = $params['bucket'];
$scheme = $params['use_ssl'] === 'false' ? 'http' : 'https';
$this->test = isset($params['test']);
$this->timeout = !isset($params['timeout']) ? 15 : $params['timeout'];
$params['region'] = !isset($params['region']) || $params['region'] === '' ? 'eu-west-1' : $params['region'];
$params['hostname'] = !isset($params['hostname']) || $params['hostname'] === '' ? 's3.amazonaws.com' : $params['hostname'];
if (!isset($params['port']) || $params['port'] === '') {
$params['port'] = $params['use_ssl'] === 'false' ? 80 : 443;
}
$base_url = $scheme . '://' . $params['hostname'] . ':' . $params['port'] . '/';
$this->connection = S3Client::factory(array('key' => $params['key'], 'secret' => $params['secret'], 'base_url' => $base_url, 'region' => $params['region']));
if (!$this->connection->isValidBucketName($this->bucket)) {
throw new \Exception("The configured bucket name is invalid.");
}
if (!$this->connection->doesBucketExist($this->bucket)) {
try {
$result = $this->connection->createBucket(array('Bucket' => $this->bucket));
$this->connection->waitUntilBucketExists(array('Bucket' => $this->bucket, 'waiter.interval' => 1, 'waiter.max_attempts' => 15));
$this->testTimeout();
} catch (S3Exception $e) {
\OCP\Util::writeLog('files_external', $e->getMessage(), \OCP\Util::ERROR);
throw new \Exception("Creation of bucket failed.");
}
}
if (!$this->file_exists('.')) {
$result = $this->connection->putObject(array('Bucket' => $this->bucket, 'Key' => '.', 'Body' => '', 'ContentType' => 'httpd/unix-directory', 'ContentLength' => 0));
$this->testTimeout();
}
}
示例8: __construct
public function __construct()
{
parent::__construct();
$this->Order = ClassRegistry::init('Order');
$this->client = S3Client::factory(["key" => "AKIAJVCBLQ3VQQS3DJHA", "secret" => "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"]);
$this->bucket = "younique-reports";
}
示例9: register
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
/** @var \Illuminate\Config\Repository $config */
$config = $this->app->make('config');
$this->app->singleton('Intervention\\Image\\ImageManager', function (Application $app) {
return new ImageManager(array('driver' => $app->config->get('imager::driver', 'gd')));
});
$this->app->bind('TippingCanoe\\Imager\\Repository\\Image', 'TippingCanoe\\Imager\\Repository\\DbImage');
$this->app->singleton('TippingCanoe\\Imager\\Service', function (Application $app) use($config) {
//
// Amazon S3
//
if ($s3Config = $config->get('imager::s3')) {
$this->app->bind('Aws\\S3\\S3Client', function (Application $app) use($s3Config) {
return \Aws\S3\S3Client::factory($s3Config);
});
}
// Run through and call each config option as a setter on the storage method.
$storageDrivers = [];
foreach ($config->get('imager::storage', []) as $abstract => $driverConfig) {
/** @var \TippingCanoe\Imager\Storage\Driver $driver */
$driver = $app->make($abstract);
foreach ($driverConfig as $property => $value) {
$setter = studly_case('set_' . $property);
$driver->{$setter}($value);
}
$storageDrivers[$abstract] = $driver;
}
$service = new Service($app->make('TippingCanoe\\Imager\\Repository\\Image'), $app->make('Intervention\\Image\\ImageManager'), $app, $storageDrivers);
return $service;
});
}
示例10: uploadNewScreenshot
public static function uploadNewScreenshot($sid, $name, $tempFile, $tempThumb)
{
$keyData = AWSFileManager::getCredentials();
$client = S3Client::factory(array("credentials" => array("key" => $keyData->aws_access_key_id, "secret" => $keyData->aws_secret_access_key)));
$result = $client->putObject(array("Bucket" => $keyData->aws_bucket, "Key" => "screenshots/" . $sid, "SourceFile" => $tempFile, "ACL" => 'public-read', "ContentDisposition" => "attachment; filename=\"" . $name . "\""));
$result = $client->putObject(array("Bucket" => $keyData->aws_bucket, "Key" => "screenshots/thumb/" . $sid, "SourceFile" => $tempThumb, "ACL" => 'public-read', "ContentDisposition" => "attachment; filename=\"" . $name . "\""));
}
示例11: getInstance
public static function getInstance($adapter = null, $localRoot = JPATH_SITE)
{
$params = JComponentHelper::getParams('com_k2');
if (is_null($adapter)) {
$adapter = $params->get('filesystem', 'Local');
}
$key = $adapter . '|' . $localRoot;
if (empty(self::$instances[$key])) {
if ($adapter == 'Local') {
$filesystem = new Gaufrette\Filesystem(new Gaufrette\Adapter\Local($localRoot));
self::$instances[$key] = $filesystem;
} elseif ($adapter == 'AmazonS3') {
$AmazonS3AccessKey = $params->get('AmazonS3AccessKey');
$AmazonS3SecretAccessKey = $params->get('AmazonS3SecretAccessKey');
$AmazonS3Bucket = $params->get('AmazonS3Bucket');
$service = S3Client::factory(array('key' => $AmazonS3AccessKey, 'secret' => $AmazonS3SecretAccessKey));
$filesystem = new Gaufrette\Filesystem(new Gaufrette\Adapter\AwsS3($service, $AmazonS3Bucket));
self::$instances[$key] = $filesystem;
} elseif ($adapter == 'MicrosoftAzure') {
$MicrosoftAzureEndpoint = $params->get('MicrosoftAzureEndpoint');
$MicrosoftAzureAccountName = $params->get('MicrosoftAzureAccountName');
$MicrosoftAzureAccountKey = $params->get('MicrosoftAzureAccountKey');
$MicrosoftAzureContainer = $params->get('MicrosoftAzureContainer');
$connectionString = 'BlobEndpoint=' . $MicrosoftAzureEndpoint . '/;AccountName=' . $MicrosoftAzureAccountName . ';AccountKey=' . $MicrosoftAzureAccountKey;
$factory = new Gaufrette\Adapter\AzureBlobStorage\BlobProxyFactory($connectionString);
$filesystem = new Gaufrette\Filesystem(new Gaufrette\Adapter\AzureBlobStorage($factory, $MicrosoftAzureContainer));
self::$instances[$key] = $filesystem;
}
}
return self::$instances[$key];
}
示例12: __construct
public function __construct($config = array(), $autoConnect = true)
{
parent::__construct($config);
$config['region'] = $this->region;
$this->S3 = S3Client::factory($config);
$this->bucketName = $config['bucket_name'];
}
示例13: __construct
public function __construct($bucket, $con = 'default')
{
global $keys;
$array = array('credentials' => array('key' => 'AcessKey', 'secret' => 'SecretKey'), 'region' => 'Region', 'version' => 'latest');
$this->client = S3Client::factory($array);
$this->bucket = $bucket;
}
示例14: __construct
public function __construct($config, $baseFolder, $options = array())
{
$this->filesystem = new Filesystem();
// Create an Amazon S3 client object
$this->client = S3Client::factory(array('key' => $config['key'], 'secret' => $config['secret']));
$this->bucketname = $config['bucketname'];
$this->baseFolder = $baseFolder;
// Register the stream wrapper from a client object
$this->client->registerStreamWrapper();
$this->scheme = 's3://' . $this->bucketname;
if (isset($config['region'])) {
$this->client->setRegion($config['region']);
}
if (file_exists($this->scheme)) {
$this->scheme .= '/' . $baseFolder;
if (!file_exists($this->scheme)) {
$this->filesystem->mkdir($this->scheme);
}
} else {
throw new \Exception('Bucket ' . $this->bucketname . ' missing.');
}
if (isset($config['url'])) {
$this->baseUrl = trim($config['url'], '/') . '/' . $this->baseFolder;
}
if (isset($config['imagesize'])) {
$this->imagesize = (bool) $config['imagesize'];
}
}
示例15: getS3Client
private function getS3Client()
{
if (!$this->S3Client) {
$this->S3Client = S3Client::factory(array('credentials' => array('key' => br()->config()->get('AWS/S3AccessKey'), 'secret' => br()->config()->get('AWS/S3AccessSecret')), 'region' => br()->config()->get('AWS/S3Region'), 'version' => 'latest'));
}
return $this->S3Client;
}