Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Fonte Link

O autor obteve a resposta no SOenSOen, importei para cá acaso ajude outros usuários.

Use a classe S3 standalone (que eu encontrei não é muito diferente da AWS SDK) com o getObject:

/**
* Get an object
*
* @param string $bucket Bucket name
* @param string $uri Object URI
* @param mixed $saveTo Filename or resource to write to
* @return mixed
*/
public static function getObject($bucket, $uri, $saveTo = false)
{
    $rest = new S3Request('GET', $bucket, $uri, self::$endpoint);
    if ($saveTo !== false)
    {
        if (is_resource($saveTo))
            $rest->fp =& $saveTo;
        else
            if (($rest->fp = @fopen($saveTo, 'wb')) !== false)
                $rest->file = realpath($saveTo);
            else
                $rest->response->error = array('code' => 0, 'message' => 'Unable to open save file for writing: '.$saveTo);
    }
    if ($rest->response->error === false) $rest->getResponse();

    if ($rest->response->error === false && $rest->response->code !== 200)
        $rest->response->error = array('code' => $rest->response->code, 'message' => 'Unexpected HTTP status');
    if ($rest->response->error !== false)
    {
        self::__triggerError(sprintf("S3::getObject({$bucket}, {$uri}): [%s] %s",
        $rest->response->error['code'], $rest->response->error['message']), __FILE__, __LINE__);
        return false;
    }
    return $rest->response;
}

Fonte: https://aws.amazon.com/code/1448

O autor obteve a resposta no SOen, importei para cá acaso ajude outros usuários.

Use a classe S3 standalone (que eu encontrei não é muito diferente da AWS SDK) com o getObject:

/**
* Get an object
*
* @param string $bucket Bucket name
* @param string $uri Object URI
* @param mixed $saveTo Filename or resource to write to
* @return mixed
*/
public static function getObject($bucket, $uri, $saveTo = false)
{
    $rest = new S3Request('GET', $bucket, $uri, self::$endpoint);
    if ($saveTo !== false)
    {
        if (is_resource($saveTo))
            $rest->fp =& $saveTo;
        else
            if (($rest->fp = @fopen($saveTo, 'wb')) !== false)
                $rest->file = realpath($saveTo);
            else
                $rest->response->error = array('code' => 0, 'message' => 'Unable to open save file for writing: '.$saveTo);
    }
    if ($rest->response->error === false) $rest->getResponse();

    if ($rest->response->error === false && $rest->response->code !== 200)
        $rest->response->error = array('code' => $rest->response->code, 'message' => 'Unexpected HTTP status');
    if ($rest->response->error !== false)
    {
        self::__triggerError(sprintf("S3::getObject({$bucket}, {$uri}): [%s] %s",
        $rest->response->error['code'], $rest->response->error['message']), __FILE__, __LINE__);
        return false;
    }
    return $rest->response;
}

Fonte: https://aws.amazon.com/code/1448

O autor obteve a resposta no SOen, importei para cá acaso ajude outros usuários.

Use a classe S3 standalone (que eu encontrei não é muito diferente da AWS SDK) com o getObject:

/**
* Get an object
*
* @param string $bucket Bucket name
* @param string $uri Object URI
* @param mixed $saveTo Filename or resource to write to
* @return mixed
*/
public static function getObject($bucket, $uri, $saveTo = false)
{
    $rest = new S3Request('GET', $bucket, $uri, self::$endpoint);
    if ($saveTo !== false)
    {
        if (is_resource($saveTo))
            $rest->fp =& $saveTo;
        else
            if (($rest->fp = @fopen($saveTo, 'wb')) !== false)
                $rest->file = realpath($saveTo);
            else
                $rest->response->error = array('code' => 0, 'message' => 'Unable to open save file for writing: '.$saveTo);
    }
    if ($rest->response->error === false) $rest->getResponse();

    if ($rest->response->error === false && $rest->response->code !== 200)
        $rest->response->error = array('code' => $rest->response->code, 'message' => 'Unexpected HTTP status');
    if ($rest->response->error !== false)
    {
        self::__triggerError(sprintf("S3::getObject({$bucket}, {$uri}): [%s] %s",
        $rest->response->error['code'], $rest->response->error['message']), __FILE__, __LINE__);
        return false;
    }
    return $rest->response;
}

Fonte: https://aws.amazon.com/code/1448

Fonte Link
Syzoth
  • 100,5mil
  • 23
  • 169
  • 361

O autor obteve a resposta no SOen, importei para cá acaso ajude outros usuários.

Use a classe S3 standalone (que eu encontrei não é muito diferente da AWS SDK) com o getObject:

/**
* Get an object
*
* @param string $bucket Bucket name
* @param string $uri Object URI
* @param mixed $saveTo Filename or resource to write to
* @return mixed
*/
public static function getObject($bucket, $uri, $saveTo = false)
{
    $rest = new S3Request('GET', $bucket, $uri, self::$endpoint);
    if ($saveTo !== false)
    {
        if (is_resource($saveTo))
            $rest->fp =& $saveTo;
        else
            if (($rest->fp = @fopen($saveTo, 'wb')) !== false)
                $rest->file = realpath($saveTo);
            else
                $rest->response->error = array('code' => 0, 'message' => 'Unable to open save file for writing: '.$saveTo);
    }
    if ($rest->response->error === false) $rest->getResponse();

    if ($rest->response->error === false && $rest->response->code !== 200)
        $rest->response->error = array('code' => $rest->response->code, 'message' => 'Unexpected HTTP status');
    if ($rest->response->error !== false)
    {
        self::__triggerError(sprintf("S3::getObject({$bucket}, {$uri}): [%s] %s",
        $rest->response->error['code'], $rest->response->error['message']), __FILE__, __LINE__);
        return false;
    }
    return $rest->response;
}

Fonte: https://aws.amazon.com/code/1448