/** * Copies the object to another container/object * * Note that this function, because it operates within the Object Store * itself, is much faster than downloading the object and re-uploading it * to a new object. * * @param DataObject $target the target of the COPY command */ public function copy(DataObject $target) { $uri = sprintf('/%s/%s', $target->container()->name(), $target->name()); $this->getLogger()->info('Copying object to [{uri}]', array('uri' => $uri)); $response = $this->getService()->request($this->url(), 'COPY', array('Destination' => $uri)); // check response code // @codeCoverageIgnoreStart if ($response->httpStatus() > 202) { throw new Exceptions\ObjectCopyError(sprintf(Lang::translate('Error copying object [%s], status [%d] response [%s]'), $this->url(), $response->httpStatus(), $response->httpBody())); } // @codeCoverageIgnoreEnd return $response; }