Module: HeadshotSupport
- Included in:
- HeadshotController
- Defined in:
- lib/app/lib/headshot_support.rb
Instance Method Summary collapse
- #headshot_file_path ⇒ Object
- #headshot_file_timestamp ⇒ Object
- #headshot_image_url(file_name) ⇒ Object
- #headshot_save_image(file_path, raw_jpeg_data) ⇒ Object
Instance Method Details
#headshot_file_path ⇒ Object
2 3 4 5 |
# File 'lib/app/lib/headshot_support.rb', line 2 def headshot_file_path file_name = "headshot_capture_#{}.jpg" File.join(Rails.root, 'public', 'headshots', file_name) end |
#headshot_file_timestamp ⇒ Object
27 28 29 |
# File 'lib/app/lib/headshot_support.rb', line 27 def "#{rand(10000)}_#{Time.now.to_i}" end |
#headshot_image_url(file_name) ⇒ Object
7 8 9 |
# File 'lib/app/lib/headshot_support.rb', line 7 def headshot_image_url(file_name) 'http://' + request.host_with_port + '/headshots/' + file_name end |
#headshot_save_image(file_path, raw_jpeg_data) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/app/lib/headshot_support.rb', line 11 def headshot_save_image(file_path, raw_jpeg_data) if raw_jpeg_data begin File.open(file_path, 'wb') do |file| file.write raw_jpeg_data end rescue raise "Headshot: cannot save headshot on #{file_path}. Please check file permissions." end else return nil end true end |