Explore
Topics
Recent Comments
- These code examples would certainly benefit from some TLC applied. Like formatting and getting...
Evgeniy Dolzhenko
- I had checked, and tested a lot of time. It work well and flexible on IE, FF, and Chrome *But, in Chrome...
Phong Tran
- hi! i am working with cascades and i would like to use a hands detector and apply a kalman filter to follow...
rachel
- These code examples would certainly benefit from some TLC applied. Like formatting and getting...
Related Posts
Amazon Web ServicesELC is one of the few groups in the world who can help you build highly scalable businesses on Amazon's low-cost Web Services platform.
Copy S3 assets with right_aws
Lately, I’ve been using right_aws to interact with S3. One thing that I found helpful was copying assets between buckets and keeping the same permissions on them. However, it’s not as simple as just copying the assets over. You need to get the Access Control Policy from the source and put it in the copied asset.
Here’s a snippet of code that does the magic.
require 'rubygems'
require 'right_aws'
s3=RightAws::S3Interface.new(S3_KEY, S3_SECRET)
s3.copy(SOURCE_BUCKET, SOURCE_PATH, DESTINATION_BUCKET, DESTINATION_PATH, :copy, {"Cache-Control" => 'max-age=315360000', "Expires" => '315360000'})
acl_prop=s3.get_acl(SOURCE_BUCKET, SOURCE_PATH)
s3.put_acl(DESTINATION_BUCKET, DESTINATION, acl_prop[:object])