Beispiel #1
0
 /**
  * Restores an item from AWS Glacier using the provided bucket name and key.
  * 
  * @param string $sBucket
  * @param string $sKey
  * @param integer $iDays
  * @return string
  */
 public function restoreItem($sBucket, $sKey, $iDays = 1)
 {
     $oS3Client = $this->oAwsClient->get(self::SERVICE_S3);
     //Filtering the days argument, must be a non zero int
     $iFilteredDays = \is_int($iDays) && $iDays > 0 ? $iDays : 1;
     $aReturns = array();
     $aReturns['status'] = 500;
     $aReturns['RequestId'] = '';
     $aReturns['message'] = 'Restore has failed for ' . $sKey;
     try {
         $oGuzzle = $oS3Client->restoreObject(array('Bucket' => $sBucket, 'Key' => $sKey, 'Days' => $iFilteredDays));
         if (\is_string($oGuzzle->get('RequestId')) && $oGuzzle->get('RequestId') != '') {
             $aReturns['status'] = 200;
             $aReturns['RequestId'] = $oGuzzle->get('RequestId');
             $aReturns['message'] = 'Restore completed for ' . $sKey;
         }
     } catch (\Exception $oExp) {
         $aReturns['message'] = 'Restore has failed for ' . $sKey . '. ' . $oExp->getMessage();
     }
     return \json_encode($aReturns);
 }