public function object($name, $requireSSL = TRUE) {

    $url = self::objectUrl($this->url, $name);
    $cdn = self::objectUrl($this->cdnUrl, $name);
    $cdnSsl = self::objectUrl($this->cdnSslUrl, $name);
    $headers = array();

    // Auth token.
    $headers['X-Auth-Token'] = $this->token;

    $client = \HPCloud\Transport::instance();

    if (empty($this->cdnUrl)) {
      $response = $client->doRequest($url, 'GET', $headers);
    }
    else {
      $from = $requireSSL ? $cdnSsl : $cdn;
      // print "Fetching object from $from\n";
      $response = $client->doRequest($from, 'GET', $headers);
    }

    if ($response->status() != 200) {
      throw new \HPCloud\Exception('An unknown error occurred while saving: ' . $response->status());
    }

    $remoteObject = RemoteObject::newFromHeaders($name, $response->headers(), $this->token, $url);
    $remoteObject->setContent($response->content());

    if (!empty($this->cdnUrl)) {
      $remoteObject->useCDN($cdn, $cdnSsl);
    }

    return $remoteObject;
  }
public function object($name, $requireSSL = TRUE) {

    $url = self::objectUrl($this->url, $name);
    $cdn = self::objectUrl($this->cdnUrl, $name);
    $cdnSsl = self::objectUrl($this->cdnSslUrl, $name);
    $headers = array();

    // Auth token.
    $headers['X-Auth-Token'] = $this->token;

    $client = \HPCloud\Transport::instance();

    if (empty($this->cdnUrl)) {
      $response = $client->doRequest($url, 'GET', $headers);
    }
    else {
      $from = $requireSSL ? $cdnSsl : $cdn;
      // print "Fetching object from $from\n";
      $response = $client->doRequest($from, 'GET', $headers);
    }

    if ($response->status() != 200) {
      throw new \HPCloud\Exception('An unknown error occurred while saving: ' . $response->status());
    }

    $remoteObject = RemoteObject::newFromHeaders($name, $response->headers(), $this->token, $url);
    $remoteObject->setContent($response->content());

    if (!empty($this->cdnUrl)) {
      $remoteObject->useCDN($cdn, $cdnSsl);
    }

    return $remoteObject;
  }
public function object ( $ name , $ requireSSL = TRUE ) { $ url = self :: objectUrl ( $ this -> url , $ name ) ; $ cdn = self :: objectUrl ( $ this -> cdnUrl , $ name ) ; $ cdnSsl = self :: objectUrl ( $ this -> cdnSslUrl , $ name ) ; $ headers = array ( ) ; // Auth token. $ headers [ 'X-Auth-Token' ] = $ this -> token ; $ client = \ HPCloud \ Transport :: instance ( ) ; if ( empty ( $ this -> cdnUrl ) ) { $ response = $ client -> doRequest ( $ url , 'GET' , $ headers ) ; } else { $ from = $ requireSSL ? $ cdnSsl : $ cdn ; // print "Fetching object from $from\n"; $ response = $ client -> doRequest ( $ from , 'GET' , $ headers ) ; } if ( $ response -> status ( ) != 200 ) { throw new \ HPCloud \ Exception ( 'An unknown error occurred while saving: ' . $ response -> status ( ) ) ; } $ remoteObject = RemoteObject :: newFromHeaders ( $ name , $ response -> headers ( ) , $ this -> token , $ url ) ; $ remoteObject -> setContent ( $ response -> content ( ) ) ; if ( ! empty ( $ this -> cdnUrl ) ) { $ remoteObject -> useCDN ( $ cdn , $ cdnSsl ) ; } return $ remoteObject ; }
Get the object with the given name.

This fetches a single object with the given name. It downloads the
entire object at once. This is useful if the object is small (under
a few megabytes) and the content of the object will be used. For
example, this is the right operation for accessing a text file
whose contents will be processed.

For larger files or files whose content may never be accessed, use
remoteObject(), which delays loading the content until one of its
content methods (e.g. RemoteObject::content()) is called.

This does not yet support the following features of Swift:

- Byte range queries.
- If-Modified-Since/If-Unmodified-Since
- If-Match/If-None-Match

If a CDN has been specified either using useCDN() or
ObjectStorage::useCDN(), this will attempt to fetch the object
from the CDN.

@param string $name
The name of the object to load.
@param boolean $requireSSL
If this is TRUE (the default), then SSL will always be
used. If this is FALSE, then CDN-based fetching will
use non-SSL, which is faster.
@retval HPCloud::Storage::ObjectStorage::RemoteObject
@return \HPCloud\Storage\ObjectStorage\RemoteObject
A remote object with the content already stored locally.
Get the object with the given name .