Closed mtparet closed 11 years ago
The documented return type is incorrect. The current behavior is intentional. I will update the docs to indicate that it returns a ObjectVersion
when versioning is enabled on the bucket.
That said, it is very easy to get the object from an object version:
$ aws-rb
AWS> obj_version = AWS.s3.buckets['my-versioned-bucket'].objects['key'].write('data')
<AWS::S3::ObjectVersion:my-versioned-bucket:key:9MHtaVle8bWn1BtdFruEtu0IDoqA5fjy>
AWS> obj_version.object
=> <AWS::S3::S3Object:my-versioned-bucket/foo>
Thanks a lot to have updated the documentation. However I still think this behavior add not necessary complexity. (dealing with two kinds of object returned from a same method/parameters)
Calling the instance method
create
on anAWS::S3::ObjectCollection
is not consistency and return anAWS::S3::ObjectVersion
(if the bucket has versioning activated) instead of anAWS::S3::S3Object
.Also this doesn't match the documentation: http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/S3/ObjectCollection.html#create-instance_method
The side-effect of this problem is that we can't use others usual S3 operations (like
copy_to
) with this object.We should receive an S3Object and be able to retrieve the S3::ObjectVersion from this one to avoid to deal with a method returning different kind of objects.