コード例 #1
0
 /**
  * @return int
  */
 public function getPageNumber()
 {
     if (null === $this->pageNumber) {
         AsposeApp::getLogger()->error('PageNumber is not set for this event.');
         throw new AsposeCloudException('PageNumber is not set for this event.');
     }
     return $this->pageNumber;
 }
コード例 #2
0
 /**
  * @return string
  */
 public function getFileName()
 {
     if ($this->fileName == '') {
         AsposeApp::getLogger()->error(Exception::MSG_NO_FILENAME);
         throw new Exception(Exception::MSG_NO_FILENAME);
     }
     return $this->fileName;
 }
コード例 #3
0
 /**
  * Copies a file in Aspose storage to a new destination
  *
  * @param string $fileName The name of file.
  * @param string $storageName The name of storage.
  * @return bool
  * @throws Exception
  */
 public function copyFile($fileName, $storageName = '', $newDest)
 {
     //check whether file is set or not
     if ($fileName == '' || $newDest == '') {
         AsposeApp::getLogger()->error(Exception::MSG_NO_FILENAME);
         throw new Exception(Exception::MSG_NO_FILENAME);
     }
     //build URI
     $strURI = $this->strURIFile . $fileName . '?newdest=' . $newDest;
     if ($storageName != '') {
         $strURI .= '&storage=' . $storageName;
     }
     //sign URI
     $signedURI = Utils::sign($strURI);
     $responseStream = Utils::processCommand($signedURI, 'PUT', '', '');
     $json = json_decode($responseStream);
     if ($json->Code === 200) {
         return true;
     }
     return false;
 }
コード例 #4
0
 /**
  * Get file from Aspose storage.
  *
  * @param string $fileName The name of file.
  * @param string $storageName The name of storage.
  *
  * @return array
  * @throws Exception
  */
 public function getFile($fileName, $storageName = '')
 {
     //check whether file is set or not
     if ($fileName == '') {
         AsposeApp::getLogger()->error(Exception::MSG_NO_FILENAME);
         throw new Exception(Exception::MSG_NO_FILENAME);
     }
     //build URI
     $strURI = $this->strURIFile . $fileName;
     if ($storageName != '') {
         $strURI .= '?storage=' . $storageName;
     }
     //sign URI
     $signedURI = Utils::sign($strURI);
     $responseStream = Utils::processCommand($signedURI, 'GET', '', '');
     return $responseStream;
 }
コード例 #5
0
 public static function sign($urlToSign)
 {
     // parse the url
     $urlToSign = rtrim($urlToSign, "/");
     $url = parse_url($urlToSign);
     $urlPartToSign = $url['scheme'] . '://' . $url['host'] . str_replace(array(' ', '+'), array('%20', '%2B'), $url['path']);
     if (isset($url['query']) && !empty($url['query'])) {
         $urlPartToSign .= "?" . str_replace(array(' ', '+'), array('%20', '%2B'), $url['query']) . '&appSID=' . AsposeApp::$appSID;
     } else {
         $urlPartToSign .= '?appSID=' . AsposeApp::$appSID;
     }
     // Create a signature using the private key and the URL-encoded
     // string using HMAC SHA1. This signature will be binary.
     $signature = hash_hmac('sha1', $urlPartToSign, AsposeApp::$appKey, true);
     $encodedSignature = self::encodeBase64UrlSafe($signature);
     $encodedSignature = str_replace(array('=', '-', '_'), array('', '%2b', '%2f'), $encodedSignature);
     preg_match_all("/%[0-9a-f]{2}/", $encodedSignature, $m);
     foreach ($m[0] as $code) {
         $encodedSignature = str_replace($code, strtoupper($code), $encodedSignature);
     }
     $returnUrl = $urlPartToSign . '&signature=' . $encodedSignature;
     AsposeApp::getLogger()->debug("Aspose Cloud SDK: url signed", array('urlToSign' => $urlToSign, 'returnUrl' => $returnUrl));
     return $returnUrl;
 }