Example #1
0
 /**
  * Constructor
  * 
  * @param  array|Zend_Config $options 
  * @return void
  */
 function __construct($options = array())
 {
     if ($options instanceof Zend_Config) {
         $options = $options->toArray();
     }
     if (!is_array($options)) {
         throw new Zend_Cloud_StorageService_Exception('Invalid options provided');
     }
     $auth = array('username' => $options[self::USERNAME], 'password' => $options[self::PASSWORD], 'appKey' => $options[self::APP_KEY]);
     $nirvanix_options = array();
     if (isset($options[self::HTTP_ADAPTER])) {
         $httpc = new Zend_Http_Client();
         $httpc->setAdapter($options[self::HTTP_ADAPTER]);
         $nirvanix_options['httpClient'] = $httpc;
     }
     try {
         $this->_nirvanix = new Zend_Service_Nirvanix($auth, $nirvanix_options);
         $this->_remoteDirectory = $options[self::REMOTE_DIRECTORY];
         $this->_imfNs = $this->_nirvanix->getService('IMFS');
         $this->_metadataNs = $this->_nirvanix->getService('Metadata');
     } catch (Zend_Service_Nirvanix_Exception $e) {
         throw new Zend_Cloud_StorageService_Exception('Error on create: ' . $e->getMessage(), $e->getCode(), $e);
     }
 }
<?php

require_once 'Zend/Service/Nirvanix.php';
$auth = array('username' => 'nome utente', 'password' => 'password', 'appKey' => 'application key');
$nirvanix = new Zend_Service_Nirvanix($auth);
$imfs = $nirvanix->getService('IMFS');
$data = file_get_contents('/my/local/dir/picture.jpg');
$imfs->putContents('/picture.jpg', $data);
header('Accept-Ranges: bytes');
header('Content-Length: ' . strlen($data));
header('Content-Type: image/jpeg');
echo $imfs->getContents('/picture.jpg');