dwilkie / carrierwave_direct

Process your uploads in the background by uploading directly to S3
MIT License
839 stars 181 forks source link

Allows the policy method to accept a block #196

Closed rauhryan closed 8 years ago

rauhryan commented 8 years ago

The policy generation method now accepts a block and yields the conditions hash in order to add custom rules.

The use case for this is to enable server-side encryption on amazon S3.

AWS documentation

When POSTing directly to S3, you need to include a config value in the form object `x-amz-server-side​-encryption'

If you do that the POST will be rejected because the policy document doesn't match the same parameters that are being send and it will throw an extra parameter error.

I've added a yield on the conditions so that I can just muck with them however I see fit.

I've forked the gem and the changes work perfect for my needs, I'm willing to make some modifications if you need me to but I'd like to get this contributed to the library so that we do not have to maintain our own fork.

Thanks for the great library and let me know if I can be of any further help, I look forward to your feedback

Cheers :beers: