Added save_to_file as helper to get attachments for testing assets.

This commit is contained in:
Martin Edenhofer 2017-06-06 14:11:28 +02:00
parent f3a7b5415d
commit e3c90174ee

View file

@ -139,6 +139,19 @@ returns
true true
end end
=begin
get content of file
store = Store.find(store_id)
content_as_string = store.content
returns
content_as_string
=end
def content def content
file = Store::File.find_by(id: store_file_id) file = Store::File.find_by(id: store_file_id)
if !file if !file
@ -147,6 +160,34 @@ returns
file.content file.content
end 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 def provider
file = Store::File.find_by(id: store_file_id) file = Store::File.find_by(id: store_file_id)
if !file if !file