Update benefits.rb accept binary file types.
The modification allows binary file types (e.g. MS word docs) to be uploaded without encountering encoding errors
This commit is contained in:
@@ -4,7 +4,7 @@ class Benefits < ActiveRecord::Base
|
|||||||
def self.save(file, backup=false)
|
def self.save(file, backup=false)
|
||||||
data_path = Rails.root.join("public", "data")
|
data_path = Rails.root.join("public", "data")
|
||||||
full_file_name = "#{data_path}/#{file.original_filename}"
|
full_file_name = "#{data_path}/#{file.original_filename}"
|
||||||
f = File.open(full_file_name, "w+")
|
f = File.open(full_file_name, "wb+")
|
||||||
f.write file.read
|
f.write file.read
|
||||||
f.close
|
f.close
|
||||||
make_backup(file, data_path, full_file_name) if backup == "true"
|
make_backup(file, data_path, full_file_name) if backup == "true"
|
||||||
|
|||||||
Reference in New Issue
Block a user