本文整理汇总了PHP中OpenCloud\Rackspace::objectStoreService方法的典型用法代码示例。如果您正苦于以下问题:PHP Rackspace::objectStoreService方法的具体用法?PHP Rackspace::objectStoreService怎么用?PHP Rackspace::objectStoreService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenCloud\Rackspace
的用法示例。
在下文中一共展示了Rackspace::objectStoreService方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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']));
}
示例2: getAdapter
public function getAdapter()
{
$client = new Rackspace(Rackspace::US_IDENTITY_ENDPOINT, array('username' => $this->config['username'], 'apiKey' => $this->config['apiKey']));
$store = $client->objectStoreService(null, $this->config['region']);
$container = $store->getContainer($this->config['container']);
return new Adapter($container);
}
示例3: get_service
public function get_service($opts, $useservercerts = false, $disablesslverify = null)
{
$user = $opts['user'];
$apikey = $opts['apikey'];
$authurl = $opts['authurl'];
$region = !empty($opts['region']) ? $opts['region'] : null;
require_once UPDRAFTPLUS_DIR . '/vendor/autoload.php';
global $updraftplus;
# The new authentication APIs don't match the values we were storing before
$new_authurl = 'https://lon.auth.api.rackspacecloud.com' == $authurl || 'uk' == $authurl ? Rackspace::UK_IDENTITY_ENDPOINT : Rackspace::US_IDENTITY_ENDPOINT;
if (null === $disablesslverify) {
$disablesslverify = UpdraftPlus_Options::get_updraft_option('updraft_ssl_disableverify');
}
if (empty($user) || empty($apikey)) {
throw new Exception(__('Authorisation failed (check your credentials)', 'updraftplus'));
}
$updraftplus->log("Cloud Files authentication URL: " . $new_authurl);
$client = new Rackspace($new_authurl, array('username' => $user, 'apiKey' => $apikey));
$this->client = $client;
if ($disablesslverify) {
$client->setSslVerification(false);
} else {
if ($useservercerts) {
$client->setConfig(array($client::SSL_CERT_AUTHORITY, 'system'));
} else {
$client->setSslVerification(UPDRAFTPLUS_DIR . '/includes/cacert.pem', true, 2);
}
}
return $client->objectStoreService('cloudFiles', $region);
}
示例4: __construct
public function __construct(callable $conf)
{
$client = new Rackspace($conf('FS_RACK_ENDPOINT'), ['username' => $conf('FS_RACK_USERNAME'), 'apiKey' => $conf('FS_RACK_API_KEY')]);
$store = $client->objectStoreService('cloudFiles', $conf('FS_RACK_REGION'), $conf('FS_RACK_URL_TYPE'));
$container = $store->getContainer($conf('FS_RACK_CONTAINER'));
$adapter = new RackspaceAdapter($container);
$this->constructFileSystem($adapter);
}
示例5: getContainer
/**
* @return \OpenCloud\ObjectStore\Resource\Container
*/
protected function getContainer()
{
if (!isset($this->container)) {
$client = new Rackspace(Rackspace::US_IDENTITY_ENDPOINT, array('username' => $this->config[self::USERNAME], 'apiKey' => $this->config[self::API_KEY]));
$service = $client->objectStoreService('cloudFiles', $this->config[self::REGION], empty($this->config[self::SERVICE_NET]) ? 'publicURL' : 'internalURL');
$this->container = $service->getContainer($this->containerName);
}
return $this->container;
}
开发者ID:helpfulrobot,项目名称:markguinn-silverstripe-cloudassets-rackspace,代码行数:12,代码来源:RackspaceBucket.php
示例6: get_container_connection
private function get_container_connection()
{
if (!$this->container) {
$client = new Rackspace(Rackspace::UK_IDENTITY_ENDPOINT, array('username' => env('RACKSPACE_USERNAME'), 'apiKey' => env('RACKSPACE_KEY')));
$region = env('RACKSPACE_REGION');
$objectStoreService = $client->objectStoreService(null, $region);
$this->container = $objectStoreService->getContainer(env('RACKSPACE_CONTAINER'));
}
return $this->container;
}
示例7: getRemoteClient
/**
* Returns the remote transport client
* @param array $params
* @param string $include_container
* @return \OpenCloud\ObjectStore\Resource\Container|\OpenCloud\ObjectStore\Service
*/
public static function getRemoteClient(array $params, $include_container = true)
{
$url = isset($params['rcf_location']) && strtolower($params['rcf_location']) == 'uk' ? Rackspace::UK_IDENTITY_ENDPOINT : Rackspace::US_IDENTITY_ENDPOINT;
$client = new Rackspace($url, ['username' => $params['rcf_username'], 'apiKey' => $params['rcf_api']]);
$client->authenticate();
$store = $client->objectStoreService('cloudFiles');
if ($include_container) {
return $store->getContainer($params['rcf_container']);
}
return $store;
}
示例8: getRackspaceContainer
/**
* Get the Rackspace Cloud Files container.
*
* @param \OpenCloud\Rackspace $client
* @param array $config
* @return \OpenCloud\ObjectStore\Resource\Container
*/
protected function getRackspaceContainer(Rackspace $client, array $config)
{
$urlType = Arr::get($config, 'url_type');
$store = $client->objectStoreService('cloudFiles', $config['region'], $urlType);
return $store->getContainer($config['container']);
}
示例9: dirname
<?php
/**
* Copyright 2012-2014 Rackspace US, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require dirname(__DIR__) . '/../vendor/autoload.php';
use OpenCloud\Rackspace;
// 1. Instantiate a Rackspace client. You can replace {authUrl} with
// Rackspace::US_IDENTITY_ENDPOINT or similar
$client = new Rackspace('{authUrl}', array('username' => '{username}', 'apiKey' => '{apiKey}'));
// 2. Obtain an Object Store service object from the client.
$objectStoreService = $client->objectStoreService(null, '{region}');
// Get all containers
$containers = $objectStoreService->listContainers();
// Delete them
foreach ($containers as $container) {
$container->delete(true);
}
示例10: onCreate
/**
* @param mixed[] $config
* @return AdapterInterface
*/
protected function onCreate($config = [])
{
$client = new Rackspace($this->param($config, 'identityEndpoint'), $this->params($config));
$store = $client->objectStoreService($this->param($config, 'serviceName'), $this->param($config, 'serviceRegion'), $this->param($config, 'serviceUrlType'));
return new RackspaceAdapter($store->getContainer('flysystem'));
}
示例11: Rackspace
// Pre-requisites:
// * Prior to running this script, you must setup the following environment variables:
// * RAX_USERNAME: Your Rackspace Cloud Account Username, and
// * RAX_API_KEY: Your Rackspace Cloud Account API Key
// * There exists a container named 'logos' in your Object Store. Run
// create-container.php if you need to create one first.
// * The 'logos' container contains an object named 'php-elephant.jpg'. Run
// upload-object.php if you need to create it first.
//
require __DIR__ . '/../../vendor/autoload.php';
use OpenCloud\Rackspace;
// 1. Instantiate a Rackspace client.
$client = new Rackspace(Rackspace::US_IDENTITY_ENDPOINT, array('username' => getenv('RAX_USERNAME'), 'apiKey' => getenv('RAX_API_KEY')));
// 2. Obtain an Object Store service object from the client.
$region = 'DFW';
$objectStoreService = $client->objectStoreService(null, $region);
// 3. Get container.
$container = $objectStoreService->getContainer('logos');
// 4. Get object.
$objectName = 'php-elephant.jpg';
$object = $container->getObject($objectName);
/** @var $object OpenCloud\ObjectStore\Resource\DataObject **/
printf("Object name: %s\n", $object->getName());
$objectContent = $object->getContent();
/** @var $objectContent Guzzle\Http\EntityBody **/
// 5. Write object content to file on local filesystem.
$objectContent->rewind();
$stream = $objectContent->getStream();
$localFilename = tempnam("/tmp", 'php-opencloud-');
file_put_contents($localFilename, $stream);
printf("Your object has been written to %s\n", $localFilename);
示例12: imagecreatetruecolor
// RESIZE AND PRESERVE TRANSPARENCY ON EYES
$temp_image = imagecreatetruecolor($eye_image_width, $eye_image_height);
imagealphablending($temp_image, false);
imagesavealpha($temp_image, true);
$transparent = imagecolorallocatealpha($temp_image, 255, 255, 255, 127);
imagefilledrectangle($temp_image, 0, 0, $eye_image_width, $eye_image_height, $transparent);
imagecopyresampled($temp_image, $eye_image, 0, 0, 0, 0, $eye_image_width, $eye_image_height, imagesx($eye_image), imagesy($eye_image));
// get width and height of resized eye
$sx = imagesx($temp_image) - $eye_image_width / 2;
$sy = imagesy($temp_image) - $eye_image_width / 2;
imagecopy($profile_image, $temp_image, $left_eye_marge_right - $sx, $left_eye_marge_bottom - $sy, 0, 0, imagesx($temp_image), imagesy($temp_image));
imagecopy($profile_image, $temp_image, $right_eye_marge_right - $sx, $right_eye_marge_bottom - $sy, 0, 0, imagesx($temp_image), imagesy($temp_image));
}
imagepng($profile_image, __DIR__ . rand(0, 10000) . 'png');
imagedestroy($profile_image);
$objectStoreService = $client->objectStoreService(null, 'ORD');
//$container = $objectStoreService->createContainer('eyes');
$container = $objectStoreService->getContainer('tomato');
//print_r($container);
$new_image_name = rand(0, 10000) . 'png';
imagepng($profile_image, __DIR__ . '/' . $new_image_name);
$localFileName = __DIR__ . '/' . $new_image_name;
$remoteFileName = $new_image_name;
$handle = fopen($localFileName, 'r');
$container->uploadObject($remoteFileName, $handle);
//fclose($handle);
//print_r($container);
header('Content-type: text/plain');
echo 'http://9ac6f2b05dad964c4500-289fb48c1e3607de5437a0c9e6e868be.r38.cf2.rackcdn.com/' . $remoteFileName;
/*
// Output and free memory
示例13: getClient
/**
* Get the rackspace client.
*
* @param string[] $auth
*
* @return \OpenCloud\ObjectStore\Resource\Container
*/
protected function getClient(array $auth)
{
$client = new OpenStackRackspace($auth['endpoint'], ['username' => $auth['username'], 'apiKey' => $auth['apiKey']]);
$urlType = array_get($auth, 'internal', false) ? 'internalURL' : 'publicURL';
return $client->objectStoreService('cloudFiles', $auth['region'], $urlType)->getContainer($auth['container']);
}
示例14: get
/**
* @param array $config
* @return Flysystem
*/
public function get(array $config)
{
$client = new Rackspace($config['endpoint'], ['username' => $config['username'], 'apiKey' => $config['key']]);
$container = $client->objectStoreService('cloudFiles', $config['zone'])->getContainer($config['container']);
return new Flysystem(new RackspaceAdapter($container, $config['root']));
}
示例15: date
<?php
/**
* Backup MySQL to Rackspace Cloud Files
*
* @author Chris Mears <chris.mears@gmail.com>
*/
date_default_timezone_set('America/Chicago');
require 'vendor/autoload.php';
require 'settings.php';
use OpenCloud\Rackspace;
echo date('[r] ') . "INFO: Backup initiated.\n";
echo date('[r] ') . "INFO: Backing up {$db} on {$dbserver}...\n";
exec("mysqldump --opt --user={$user} --password={$password} --host={$dbserver} {$db} > {$file}");
// Create gzip and force overwrite
echo date('[r] ') . "INFO: {$file} created. Compressing...\n";
exec("gzip -f {$file}");
echo date('[r] ') . "INFO: {$file}.gz created. Sending to Rackspace Cloud Files {$rackspaceContainer} container...\n";
$client = new Rackspace(Rackspace::US_IDENTITY_ENDPOINT, array('username' => $rackspaceUser, 'apiKey' => $rackspaceApiKey));
$service = $client->objectStoreService(null, $rackspaceRegion, $rackspaceUrlType);
try {
$container = $service->getContainer($rackspaceContainer);
$container->uploadObject("{$file}.gz", fopen("{$file}.gz", 'r+'));
} catch (Exception $e) {
echo date('[r] ') . "ERROR: {$file}.gz upload failed.\n";
echo date('[r] ') . "ERROR: " . $e->getMessage() . "\n";
echo date('[r] ') . "ERROR: Backup failed.\n";
exit;
}
echo date('[r] ') . "INFO: {$file}.gz uploaded.\n";
echo date('[r] ') . "SUCCESS: Backup complete.\n";