简体   繁体   English

如何在php-opencloud中正确提取存档文件

[英]How to extract archive file correctly in php-opencloud

im using version 1.7 of php-opencloud 即时通讯使用1.7版本的php-opencloud

heres some part of my code. 这是我代码的一部分。

$cloud = new Rackspace(RACKSPACE_US, $credentials);
$storage = $cloud->objectStoreService('cloudFiles', 'SYD','publicURL');
$container = $storage->getContainer('testing');

$gz_file = 'test.tar.gz';

$storage->bulkExtract('', $gz_file);

this code is working the problem is when its extracted only the first level of directories are extracted correctly, inside it the all directory name is concatenated with the filenames.. it did not create a directory for each. 这段代码起作用了,问题在于当它仅提取了第一级目录时,才正确提取了该目录,其中所有目录名都与文件名连接在一起。.它没有为每个目录创建一个目录。 im sure im missing something here. 我确定我在这里错过了一些东西。

please see screenshot: http://i.stack.imgur.com/nfXlU.png 请查看屏幕截图: http : //i.stack.imgur.com/nfXlU.png

Correct, what you are seeing is the expected behavior. 正确,您看到的是预期的行为。 Cloud Files has no concept of nested directories (namely, there is only one top-level of containers). Cloud Files没有嵌套目录的概念(即,只有一个顶层容器)。 However, you can simulate a hierarchy, like in your screenshot, by adding a delimiter (like a '/') to the object name. 但是,您可以通过在对象名称中添加定界符(例如'/')来模拟层次结构(如您的屏幕快照)。

So if your archive has a nested structure, each file path is flattened into a string before being uploaded, and that string is used as the object name. 因此,如果您的归档文件具有嵌套结构,则每个文件路径在上载之前都会先扁平化为一个字符串,然后将该字符串用作对象名称。

According to the php-opencloud docs , if you omit the container name (like you are doing in your example), then containers will be created based on the filenames inside the archive. 根据php-opencloud docs的说明 ,如果您省略容器名称(如您在示例中所做的那样),则将根据存档内的文件名创建容器。

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

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