require 'httparty' require 'tempfile' class AmazonCopy def download_video videolisting file = Tempfile.new ["video_",".mp4"], "#{Rails.root}/tmp" begin file.write HTTParty.get(videolisting.get_video_url).parsed_response.force_encoding("utf-8") file.flush ensure file.close end file.unlink end handle_asynchronously :download_video end