Issues

ZF-6860: Nirvanix upload fails in command line on Windows

Description

When trying to execute the following script in the Windows command line an exception is thrown due to dirname returning a backslash.

<?php set_include_path(get_include_path() . PATH_SEPARATOR . 'C:\Program Files\PHP\ZendFramework-1.8.2-minimal\library'); require_once 'C:\Program Files\PHP\ZendFramework-1.8.2-minimal\library\Zend\Service\Nirvanix.php'; $auth = array('username' => 'userforzendbug', 'password' => 'zendpass', 'appKey' => '1a6df3fd-c81d-4cbf-9a97-27110926e916'); $nirvanix = new Zend_Service_Nirvanix($auth); $imfs = $nirvanix->getService('IMFS'); $result = $imfs->putContents('/foo.txt', 'fourteen bytes'); print_r($result); ?>

In library/Zend/Services/Nirvanix/Namespace/Imfs.php at line 85:

... $this->_httpClient->setParameterPost('destFolderPath', dirname($filePath)); $this->_httpClient->setFileUpload(basename($filePath), 'uploadFile', $data, $mimeType); $response = $this->_httpClient->request(Zend_Http_Client::POST); ...

The fix is to always pass Nirvanix a forward slash. The replacement for line 85 could be something like a str_replace for the slash.

    $this->_httpClient->setParameterPost('destFolderPath', str_replace("\\", "/", dirname($filePath)));

Comments

after str_replace(" there should be a backslash backslash but it seems to have been stripped out.

Fixed in r18283