diff --git a/app/models/store.rb b/app/models/store.rb index a5ea0520c..d423b90bc 100644 --- a/app/models/store.rb +++ b/app/models/store.rb @@ -139,6 +139,19 @@ returns true end +=begin + +get content of file + + store = Store.find(store_id) + content_as_string = store.content + +returns + + content_as_string + +=end + def content file = Store::File.find_by(id: store_file_id) if !file @@ -147,6 +160,34 @@ returns file.content end +=begin + +get content of file + + store = Store.find(store_id) + location_of_file = store.save_to_file + +returns + + location_of_file + +=end + + def save_to_file(path = nil) + content + file = Store::File.find_by(id: store_file_id) + if !file + raise "No such file #{store_file_id}!" + end + if !path + path = "#{Rails.root}/tmp/#{filename}" + end + ::File.open(path, 'wb') { |handle| + handle.write file.content + } + path + end + def provider file = Store::File.find_by(id: store_file_id) if !file