简体   繁体   中英

Rackspace php-opencloud how do I create a folder

When I upload a file using $container->uploadObjects($files) I can include the directory path in the name to make a new folder. If I use Cyberduck I can see the new folder.

But if I try and get an object list with $container->objectList($options) it doesn't list the directory like [content_type] => application/directory . But it does when I use Cyberduck.

So my question is, how do I create a folder using php-opencloud?

This is not related to php-opencloud specifically, but it's a limitation of CloudFiles. Much like AWS S3 and other distributed object stores, you can't have directories inside buckets. Some software, like Cyberduck, knows that and instead it renames the files with the hierarchy as well as displaying those hierarchy as directories even though they are all in the same level of a container. For detailed explanation, check this documentation out.

6 years late, but I've just had to do this myself with PHP Opencloud and figured I'd post my approach because you can actually create folders that don't contain files. You just have to set the appropriate content type when uploading:

$container = $objectStoreService->getContainer('container-name');
$container->uploadObject('folder-path-and-name-to-create', '', array('Content-Type' => 'application/directory'));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM