Ejemplo n.º 1
0
 /**
  * Moves an object
  *
  * @param string $src The path to the source file
  * @param string $dest The path to the destination file
  *
  * @return boolean The success of the operation
  */
 public function move($src, $dest)
 {
     $result = false;
     // if is folder
     if (preg_match('/\\/$/', $src)) {
         // they have a slash at the end
         // check if the folder is empty
         $objects = $this->s3->getBucket($this->bucket, $src, null, 20);
         // unset the folder being deleted
         unset($objects[$src]);
         // if they are objects in the folder, cancel
         if (!empty($objects)) {
             $this->setError(JText::_('PLG_ZLFRAMEWORK_STRG_S3_MUST_EMPTY_FOLDER'));
             return false;
         }
     }
     // Copy the object
     $result = $this->s3->copyObject($this->bucket, $src, $this->bucket, $dest, AEUtilAmazons3::ACL_BUCKET_OWNER_FULL_CONTROL, array(), array());
     // if copy success delete the original object
     if ($result === true) {
         $this->delete($src);
     }
     // propagate S3 object errors to storage object
     $this->s3->propagateToObject($this);
     // if something went wrong, report
     if ($result !== true) {
         $result = false;
         $this->setError(JText::_('PLG_ZLFRAMEWORK_STRG_ERR_SOMETHING_WENT_WRONG'));
     }
     return $result;
 }