Created
August 26, 2012 19:31
-
-
Save basgys/3482915 to your computer and use it in GitHub Desktop.
Transfer BLOB to Amazon S3 with Paperclip
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# loop on something .each do |my_model| | |
blob_to_file(my_model.blob_image) do |image_file| | |
my_model.update_attributes(s3_image: image_file) | |
end | |
# end | |
def blob_to_file(blob) | |
tfile = Tempfile.new('blob_to_file') | |
tfile.write(blob.force_encoding("UTF-8")) | |
yield(tfile) if block_given? | |
tfile.close | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment