From 4715082b46073d7ca4108b1093d2304eb5999e1b Mon Sep 17 00:00:00 2001 From: spag Date: Tue, 19 Feb 2013 14:09:11 +0100 Subject: tiff download --- app/controllers/fax_documents_controller.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'app') diff --git a/app/controllers/fax_documents_controller.rb b/app/controllers/fax_documents_controller.rb index 5653683..c2b3083 100644 --- a/app/controllers/fax_documents_controller.rb +++ b/app/controllers/fax_documents_controller.rb @@ -31,6 +31,24 @@ class FaxDocumentsController < ApplicationController ) end } + format.tiff { + caller_number = @fax_document.caller_id_number.to_s.gsub(/[^0-9]/, '') + if caller_number.blank? + caller_number = 'anonymous' + end + + if @fax_document.tiff + send_file @fax_document.tiff, :type => "image/tiff", + :filename => "#{@fax_document.created_at.strftime('%Y%m%d-%H%M%S')}-#{caller_number}.tiff" + else + render( + :status => 404, + :layout => false, + :content_type => 'text/plain', + :text => "", + ) + end + } end end -- cgit v1.2.3