Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getObjectStorageClass Method #43

Open
triwav opened this issue Apr 10, 2013 · 0 comments
Open

getObjectStorageClass Method #43

triwav opened this issue Apr 10, 2013 · 0 comments

Comments

@triwav
Copy link

triwav commented Apr 10, 2013

I'm not too familiar with github but thought I'd share a method I wrote to get the storage class of an item. I pulled most of the info from here: https://forums.aws.amazon.com/message.jspa?messageID=312224
There might be better ways to do it but the code works so thought I'd share:

/**
* Get object StorageClass
*
* @param string $bucket Bucket name
* @param string $uri Object URI
* @return string | false
*/
public static function getObjectStorageClass($bucket, $uri)
{
$rest = new S3Request('GET', $bucket, '', self::$endpoint);
$rest->setParameter('prefix', $uri);
$rest = $rest->getResponse();
if ($rest->error === false && ($rest->code !== 200 && $rest->code !== 404))
$rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
if ($rest->error !== false)
{
self::triggerError(sprintf("S3::getObjectStorageClass({$bucket}, {$uri}): [%s] %s",
$rest->error['code'], $rest->error['message']), __FILE
, LINE);
return false;
}
return (string) $rest->body->Contents->StorageClass;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant