views:

93

answers:

3

I can't seem to upload an image using Zend_Service_Nirvanix. Is it even possible? I have a feeling that my problem has something to do with not being able to figure out how to set the UploadHost on the Transfer Service.

Any help is greatly appreciated! My deadline is July 16th!

Here is my code:

$nirvanix = new Zend_Service_Nirvanix(array('appKey'   => $key,
                                            'username' => $user,
                                            'password' => pass));

$NSImfs = $nirvanix->getService('IMFS');
$options = array('sizeBytes' => filesize($source));
$storageNode = $NSImfs->getStorageNode($options);

$NSTransfer = $nirvanix->getService('Transfer');
$options = array('uploadToken' => $storageNode->getStorageNode->UploadToken, 
                 'path' => $original, 
                 'fileData' => file_get_contents($source));
$result = $NSTransfer->uploadFile($options);

Here is the error I keep getting:

Zend_Service_Nirvanix_Exception: XML could not be parsed from response: Server Error in '/' Application. The resource cannot be found. Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

Requested URL: /ws/Transfer/UploadFile.ashx

in /Applications/MAMP/bin/php5/lib/php/Zend/Service/Nirvanix/Response.php on line 119

A: 

You're getting a 404?

  • Have you checked for an updated version of that library?
  • Try going into the libray and changing UploadFile.ashx to UploadFile.aspx. I don't think ashx is not a standard extension.

Maybe that will fix it.

Byron Whitlock
All the Nirvanix services use the .ashx extension. I think we are using Zend Framework version 1.7.1.
lo_fye
A: 

There's a commercial upload tool from Aurigma that has support for file and image upload to Nirvanix. Here's the link (see Uploading to Nirvanix section there) to the help topic to check.

Thanks, but no thanks. Aurigma's tool is branded. Also, it's Javascript+Java, not PHP+Flash or straight PHP.
lo_fye
A: 

To do a local upload (rather than a web upload via the browser) you just have to call the putContents method passing the files data.

Example:

$nirvanix = new Zend_Service_Nirvanix(array('appKey'   => $key,
                                            'username' => $user,
                                            'password' => pass));

$NSImfs = $nirvanix->getService('IMFS');

$response = $NSImfs->putContents($destination_file_and_path, 
                                 file_get_contents($source_file));

if($response->ResponseCode != 0)
{
    echo 'Fail!';
}

You would only call GetStorageNode if you want to generate a token to pass a browser the upload token.

lo_fye