views:

236

answers:

3

Does anyone know of a way to copy files with Paperclip using S3 for storage? Before I try to write my own, I just wanted to make sure there wasn't already a way to do this. Thanks

A: 

Paperclip supports storage to S3. Are you looking for this?

has_attached_file :profile_image, 
  :storage => :s3,
  :s3_credentials => { :access_key_id => "xxx", :secret_access_key => "yyyy" },
  :bucket => "abcd"
KandadaBoggu
Thanks but I already know how to use paperclip. I just wanted to know if paperclip supported a copy function built on the s3object.copy function.
CalebHC
+2  A: 

After some more messing around with paperclip, I figured it out. It's ridiculously simple to copy files!

# Stupid example method that just copies a user's profile pic to another user.
def copy_profile_picture(user_1, user_2)
  user_2.picture = user_1.picture
  user_2.save # Copied the picture and we're done!
end

This also works great with amazon s3. Sweet

CalebHC
A: 

CalebHC's selected answer does not work on my system. I only get an error from ImageMagick regarding "identify" and some path, which doesn't even exist on my system (Win7).

Don't really know how to work around, simply decided to remove this feature from my software for now. Still interested in why it didn't work - used a very simple case, but same error.

Michael Schmitz