sdk - How to extract archive file correctly in php-opencloud

812

im using version 1.7 of 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

644

Answer

Solution:

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). 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.

People are also looking for solutions to the problem: php - PHPMailer DSN How to get error when address not exist

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.