I have a file in aws S3 that I want to copy to an active record paperclip attachment (as a copy of the file in a different bucket).
I have a reference to the object on S3 using the aws-sdk gem:
s3 = AWS::S3.new(Rails.application.config.s3_creds)
obj = s3.buckets(uploads_bucket).objects.first
Say my active record model my_model
has
has_attached_file :some_file
How do I copy obj
into my_model.some_file
?
my_model.some_file = obj
throws:
No handler found for AWS::S3::S3Object:bucket/the_file.xls
obj.copy_to(my_model.some_file)
throws undefined method `scan' for /file_name/original/missing.png:Paperclip::Attachment