qoobaa / s3

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

Saving object as private #88

Closed jvkumar closed 9 years ago

jvkumar commented 10 years ago

@qoobaa I am trying to save object as private acl. I was looking at https://github.com/qoobaa/s3/blob/master/lib/s3/object.rb#L94 and it seems it alwasy saves as public? Please correct me if I am wrong. So I have monkeypatched s3 object save method as:

module S3
  class Object
    def content reload = false
      return @content if @content and not reload
      get_object
      @content
    end

    # Saves the object, returns true if successfull.
     def save is_private = false
      @acl = 'private' if is_private
      put_object
      true
    end
  end
end

and then call myObject.save(true) . Please let me know if there is already a way to save object as private, then I won't need this hack. Else can you add it?

qoobaa commented 10 years ago

Take a look at "acl" in S3::Object, you should just update the attribute and call save.

timwaters commented 9 years ago
new_object = bucket.objects.build("bender.png")
new_object.acl = :private
new_object.save

for the lazy :smile: