标签: php-opencloud

PHP OpenCloud\Rackspace问题

我在尝试使Rackspace Opencloud API按预期工作时遇到问题(尤其是云文件).

我一直在关注这些指南:

https://github.com/rackspace/php-opencloud/blob/master/docs/userguide/ObjectStore/Access.md http://docs.rackspace.com/sdks/api/php/namespace-OpenCloud.ObjectStore.html

身份验证似乎工作正常,因为返回了令牌和服务目录.

header("Content-Type: text/plain");
require '/vendor/autoload.php';

use OpenCloud\Rackspace;

$client = new Rackspace('https://lon.identity.api.rackspacecloud.com/v2.0/', array(
    'username' => 'MY_USERNAME',
    'apiKey'   => 'MY_APIKEY'
));

$client->authenticate();

echo 'Authenticated with token: '.$client->getToken()."\n\n";

print_r($client->getCatalog());
Run Code Online (Sandbox Code Playgroud)

当我尝试使用API​​中的服务时,我的问题开始了:

$service = $client->objectStoreService('cloudFiles');
Run Code Online (Sandbox Code Playgroud)

这行杀死了代码.我已经复制了Rackspace文档行,但仍然没有运气,我无法使任何服务工作.

任何人都可以看到我出错的地方或提供解决此问题的最佳方法的任何提示吗?

php rackspace openstack php-opencloud

4
推荐指数
1
解决办法
1270
查看次数

如何使用PHP访问架构空间打开的云容器并将文件上传到文件夹?

我使用的是作曲家包'rackspace/php-opencloud'

composer require rackspace/php-opencloud
Run Code Online (Sandbox Code Playgroud)

并尝试上传并获取文件夹中的文件列表

包括自动加载文件并添加

require 'vendor/autoload.php';
Run Code Online (Sandbox Code Playgroud)

使用文档http://docs.php-opencloud.com/en/latest/services/object-store/index.html上给出的过程,但我没有获得访问容器内的文件夹的解决方案(在我的案例中的食谱) ).如何将文件上传到容器"食谱"中的"images"和"uploads"目录中.

$client = new OpenCloud\OpenStack('{keystoneUrl}', array(
  'username' => '{username}',
  'password' => '{apiKey}',
  'tenantId' => '{tenantId}',
));

$service = $client->objectStoreService('{catalogName}', '{region}', '{urlType}');
Run Code Online (Sandbox Code Playgroud)

$ containers = $ service-> listContainers();

foreach ($containers as $container) {
    /** @param $container OpenCloud\ObjectStore\Resource\Container */
    printf("Container name: %s\n", $container->name);
    printf("Number of objects within container: %d\n", $container->getObjectCount());
}
Run Code Online (Sandbox Code Playgroud)

通过上面的代码,我可以访问容器列表,我可以设置容器,并可以获取列表

$containers = $service->listContainers();
** @param $container OpenCloud\ObjectStore\Resource\Container */
$container = $service->getContainer('{containerName}');
Run Code Online (Sandbox Code Playgroud)

php rackspace php-opencloud

3
推荐指数
1
解决办法
339
查看次数

标签 统计

php ×2

php-opencloud ×2

rackspace ×2

openstack ×1