Skip to content

Instantly share code, notes, and snippets.

@basgys
Created August 26, 2012 19:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save basgys/3482915 to your computer and use it in GitHub Desktop.
Save basgys/3482915 to your computer and use it in GitHub Desktop.
Transfer BLOB to Amazon S3 with Paperclip
# 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