qoobaa / s3

Library for accessing S3 objects and buckets, supports EU and US buckets
MIT License
258 stars 112 forks source link

obj.copy method does not parse acl argument #119

Open Nitemaeric opened 8 years ago

Nitemaeric commented 8 years ago

So, after much confusion, seems that there is a bug with the "copy_object" method.

The documentation states that you can do:

object = bucket.objects.find("lenna.png") object.copy(:key => "lenna.png", :bucket => bucket, :acl => :public_read)

But after digging around I found that the :acl => :public_read causes an InvalidArgument Error.

https://github.com/qoobaa/s3/blob/master/lib/s3/object.rb#L40 parses the acl attribute on the object for normal "saving", but for the copy method, https://github.com/qoobaa/s3/blob/master/lib/s3/object.rb#L159, this parsing is skipped, sending "publicread" to S3, which it doesn't allow. i.e. "" instead of "-".

qoobaa commented 7 years ago

Could you create a PR with a fix?

yoeran commented 7 years ago

I ran into this problem as well. My workaround is using the string public-read instead of the symbol :public_read

Example:

object = bucket.objects.find("lenna.png")
object.copy(:key => "lenna.png", :bucket => bucket, :acl => 'public-read')