|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00026 require_once 'Zend/Service/Nirvanix/Namespace/Base.php'; 00027 00037 class Zend_Service_Nirvanix_Namespace_Imfs extends Zend_Service_Nirvanix_Namespace_Base 00038 { 00048 public function getContents($filePath, $expiration = 3600) 00049 { 00050 // get url to download the file 00051 $params = array('filePath' => $filePath, 00052 'expiration' => $expiration); 00053 $resp = $this->getOptimalUrls($params); 00054 $url = (string)$resp->Download->DownloadURL; 00055 00056 // download the file 00057 $this->_httpClient->resetParameters(); 00058 $this->_httpClient->setUri($url); 00059 $resp = $this->_httpClient->request(Zend_Http_Client::GET); 00060 00061 return $resp->getBody(); 00062 } 00063 00073 public function putContents($filePath, $data, $mimeType = null) 00074 { 00075 // get storage node for upload 00076 $params = array('sizeBytes' => strlen($data)); 00077 $resp = $this->getStorageNode($params); 00078 $host = (string)$resp->GetStorageNode->UploadHost; 00079 $uploadToken = (string)$resp->GetStorageNode->UploadToken; 00080 00081 // http upload data into remote file 00082 $this->_httpClient->resetParameters(); 00083 $this->_httpClient->setUri("http://{$host}/Upload.ashx"); 00084 $this->_httpClient->setParameterPost('uploadToken', $uploadToken); 00085 $this->_httpClient->setParameterPost('destFolderPath', str_replace('\\', '/',dirname($filePath))); 00086 $this->_httpClient->setFileUpload(basename($filePath), 'uploadFile', $data, $mimeType); 00087 $response = $this->_httpClient->request(Zend_Http_Client::POST); 00088 00089 return new Zend_Service_Nirvanix_Response($response->getBody()); 00090 } 00091 00099 public function unlink($filePath) 00100 { 00101 $params = array('filePath' => $filePath); 00102 return $this->deleteFiles($params); 00103 } 00104 00105 }