[英]Rackspace OpenCloud File PHP API nested containers problems
Hi I am currently using the Rackspace OpenCloud File PHP API for the file storage in a different project however I have a requirement to use nested containers. 嗨,我目前正在使用Rackspace OpenCloud File PHP API将文件存储在另一个项目中,但是我需要使用嵌套容器。
I have a piece of software on a local pc which is mapped to a container called /Act/ 我在本地PC上有一个软件,该软件映射到名为/ Act /的容器
I need to point to the Act folder as default instead of the root folder. 我需要指向Act文件夹作为默认文件夹,而不是根文件夹。
for example: 例如:
/act/12 - Test Company/ / act / 12-测试公司/
instead of 代替
/12 - Test Company/ / 12-测试公司/
<?php
$query = "SELECT clientNAME FROM CRM_clients WHERE clientID = '$client'";
$result = mysqli_query($db, $query);
$rows = mysqli_num_rows($result);
$row = clean_fetch_assoc($result);
$name = $row['clientNAME'];
$containers = $objectStoreService->listContainers();
var_dump($containers);
$ContainerExists = 0;
foreach ($containers as $container) {
$ContainerName = $container->name;
if ( strpos($ContainerName, $client) !== false ) {
$ContainerExists = 1;
}
}
if ( $ContainerExists == 1 ) {
$containerCONCAT = $client . " - " . $name;
$container = $objectStoreService->getContainer($containerCONCAT);
}elseif ( $ContainerExists == 0 ) {
$containerCONCAT = $client . " - " . $name;
$container = $objectStoreService->createContainer($containerCONCAT);
$container = $objectStoreService->getContainer($containerCONCAT);
}
//Get list of files
$objects = $container->objectList();
?>
any ideas? 有任何想法吗?
There are a few convenience methods that you can use. 您可以使用几种便捷的方法。
When listing containers can filter by their prefix: 列出容器时可以按其前缀进行过滤:
$containers = $service->listContainers(['prefix' => $client]);
And to check whether a container exists, you can use: 要检查容器是否存在,可以使用:
$name = sprintf("%s-%s", $client, $container->name);
if ($service->containerExists($name)) {
Apart from that, you should be able to do what you want to do. 除此之外,您应该能够做自己想做的事。
If you're running into specific errors, please post them here or send a HTTP stack trace to the support e-mail listed on their developer page. 如果遇到特定错误,请在此处发布它们,或将HTTP堆栈跟踪记录 发送到其开发人员页面上列出的支持电子邮件 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.