简体   繁体   English

Rackspace php-opencloud 如何创建文件夹

[英]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.当我使用$container->uploadObjects($files)上传文件时,我可以在名称中包含目录路径以创建一个新文件夹。 If I use Cyberduck I can see the new folder.如果我使用 Cyber​​duck,我可以看到新文件夹。

But if I try and get an object list with $container->objectList($options) it doesn't list the directory like [content_type] => application/directory .但是,如果我尝试使用$container->objectList($options)获取对象列表,它不会像[content_type] => application/directory那样列出[content_type] => application/directory But it does when I use Cyberduck.但是当我使用 Cyber​​duck 时确实如此。

So my question is, how do I create a folder using php-opencloud?所以我的问题是,如何使用 php-opencloud 创建文件夹?

This is not related to php-opencloud specifically, but it's a limitation of CloudFiles.这与 php-opencloud 没有特别的关系,但它是 CloudFiles 的限制。 Much like AWS S3 and other distributed object stores, you can't have directories inside buckets.与 AWS S3 和其他分布式对象存储非常相似,存储桶中不能有目录。 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.一些软件,如 Cyber​​duck,知道这一点,而是使用层次结构重命名文件,并将这些层次结构显示为目录,即使它们都在容器的同一级别中。 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.晚了 6 年,但我只需要自己使用 PHP Opencloud 来做这件事,我想我会发布我的方法,因为您实际上可以创建不包含文件的文件夹。 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'));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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