public function copy(Object $obj, $newName, $container = NULL) {
    //$sourceUrl = $obj->url(); // This doesn't work with Object; only with RemoteObject.
    $sourceUrl = self::objectUrl($this->url, $obj->name());

    if (empty($newName)) {
      throw new \HPCloud\Exception("An object name is required to copy the object.");
    }

    // Figure out what container we store in.
    if (empty($container)) {
      $container = $this->name;
    }
    $container = rawurlencode($container);
    $destUrl = self::objectUrl('/' . $container, $newName);

    $headers = array(
      'X-Auth-Token' => $this->token,
      'Destination' => $destUrl,
    );

    $client = \HPCloud\Transport::instance();
    $response = $client->doRequest($sourceUrl, 'COPY', $headers);

    if ($response->status() != 201) {
      throw new \HPCloud\Exception("An unknown condition occurred during copy. " . $response->status());
    }
    return TRUE;
  }
public function copy(Object $obj, $newName, $container = NULL) {
    //$sourceUrl = $obj->url(); // This doesn't work with Object; only with RemoteObject.
    $sourceUrl = self::objectUrl($this->url, $obj->name());

    if (empty($newName)) {
      throw new \HPCloud\Exception("An object name is required to copy the object.");
    }

    // Figure out what container we store in.
    if (empty($container)) {
      $container = $this->name;
    }
    $container = rawurlencode($container);
    $destUrl = self::objectUrl('/' . $container, $newName);

    $headers = array(
      'X-Auth-Token' => $this->token,
      'Destination' => $destUrl,
    );

    $client = \HPCloud\Transport::instance();
    $response = $client->doRequest($sourceUrl, 'COPY', $headers);

    if ($response->status() != 201) {
      throw new \HPCloud\Exception("An unknown condition occurred during copy. " . $response->status());
    }
    return TRUE;
  }
public function copy ( Object $ obj , $ newName , $ container = NULL ) { //$sourceUrl = $obj->url(); // This doesn't work with Object; only with RemoteObject. $ sourceUrl = self :: objectUrl ( $ this -> url , $ obj -> name ( ) ) ; if ( empty ( $ newName ) ) { throw new \ HPCloud \ Exception ( "An object name is required to copy the object." ) ; } // Figure out what container we store in. if ( empty ( $ container ) ) { $ container = $ this -> name ; } $ container = rawurlencode ( $ container ) ; $ destUrl = self :: objectUrl ( '/' . $ container , $ newName ) ; $ headers = array ( 'X-Auth-Token' => $ this -> token , 'Destination' => $ destUrl , ) ; $ client = \ HPCloud \ Transport :: instance ( ) ; $ response = $ client -> doRequest ( $ sourceUrl , 'COPY' , $ headers ) ; if ( $ response -> status ( ) != 201 ) { throw new \ HPCloud \ Exception ( "An unknown condition occurred during copy. " . $ response -> status ( ) ) ; } return TRUE ; }
Copy an object to another place in object storage.

An object can be copied within a container. Essentially, this will
give you duplicates of the file, each with a new name.

An object can be copied to another container if the name of the
other container is specified, and if that container already exists.

Note that there is no MOVE operation. You must copy and then DELETE
in order to achieve that.

@param object $obj HPCloud::Storage::ObjectStorage::Object
The object to copy. This object MUST already be saved on the
remote server. The body of the object is not sent. Instead, the
copy operation is performed on the remote server. You can, and
probably should, use a RemoteObject here.
@param string $newName
The new name of this object. If you are copying across
containers, the name can be the same. If you are copying within
the same container, though, you will need to supply a new name.
@param string $container
The name of the alternate container. If this is set, the object
will be saved into this container. If this is not sent, the copy
will be performed inside of the original container.
Copy an object to another place in object storage .