0

I'm generating a fog pre-signed URL for AWS using the following snippet:

bucket = "..."
object = "demo.jpg"
expires = Integer(Time.now + 4.hours)
headers = {}
options = { path_style: true }
fog.put_object_url(bucket, object, expires, headers, options)

This works great - except that the uploaded objects aren't accessible to the public. How can a public-read access control list (ACL) be applied to the upload path?

Kevin Sylvestre
  • 37,288
  • 33
  • 152
  • 232

1 Answers1

3

You have to list these extra parameters (eg. x-amz-acl, Content-Type) under the "query" key of the options hash.

So your example would be.

bucket = "..."
object = "demo.jpg"
expires = Integer(Time.now + 4.hours)
headers = {}
query = {"x-amz-acl" => "public-read"}
options = { path_style: true, query: query }
fog.put_object_url(bucket, object, expires, headers, options)

You have probably solved this by now but incase anyone else is stuck on this, as the lack of surrounding documentation does not make it very straight forward to implement.

Jonny-W
  • 33
  • 5