amazon-archives/aws-sdk-core-ruby

Unable to fetch just the metadata

Closed this issue · 4 comments

It seems there's no way to fetch just the metadata in v2 of the sdk.

In v1, S3Object has a metadata method.

This seems to be gone in v2. The only thing I can see that's similar is to use S3::Object's get method which unfortunately retrieves the whole object wasting bandwidth.

Update:
Closed as this repo is moved. Opened an issue here aws/aws-sdk-ruby#722

Use the #head_object method.

Sorry, to be more clear. Use the head object method of the client class or the #metadata method of S3::Object.

That works well. Thanks.

Might I propose a head_object method for the S3::ObjectSummary class in the future?

@chenkirk You can also cast a S3::ObjectSummary to a S3::Object using the #object method:

s3.bucket('aws-sdk').objects.each do |obj_summary|
  obj = obj_summary.object
  puts obj.metdata.inspect # WARNING : makes one HEAD Object request for each obj in the bucket
end

Adding a #head method directly to the ObjectSummary class isn't a bad idea.