X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/041059690882d6420fd8bd087bb28e5cb2ea9123..172a71e3f242f74a6eb1f7bb45fb4d5f3ddff5e7:/app/models/trace.rb diff --git a/app/models/trace.rb b/app/models/trace.rb index 17f8ebc1e..bdafdd9d5 100644 --- a/app/models/trace.rb +++ b/app/models/trace.rb @@ -300,6 +300,26 @@ class Trace < ApplicationRecord end end + def migrate_to_storage! + file.attach(:io => File.open(trace_name), + :filename => name, + :content_type => content_type(trace_name), + :identify => false) + + if inserted + image.attach(:io => File.open(large_picture_name), + :filename => "#{id}.gif", + :content_type => "image/gif") + icon.attach(:io => File.open(icon_picture_name), + :filename => "#{id}_icon.gif", + :content_type => "image/gif") + end + + save! + + remove_files + end + private def content_type(file)