From f9497e2e3e299b5528c2938497999565f42b7555 Mon Sep 17 00:00:00 2001 From: aignatov-bio Date: Mon, 7 Oct 2019 16:21:11 +0200 Subject: [PATCH] Fix TinyMCE import from ELN --- app/utilities/protocols_importer.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/utilities/protocols_importer.rb b/app/utilities/protocols_importer.rb index 131e25312..cb642648a 100644 --- a/app/utilities/protocols_importer.rb +++ b/app/utilities/protocols_importer.rb @@ -157,10 +157,11 @@ module ProtocolsImporter # Decode the file bytes file = StringIO.new(Base64.decode64(tiny_mce_img_json['bytes'])) - tiny_mce_img.image.attach(io: file, + to_blob = ActiveStorage::Blob.create_after_upload!(io: file, filename: tiny_mce_img_json['fileName'], content_type: tiny_mce_img_json['fileType'], metadata: JSON.parse(tiny_mce_img_json['fileMetadata'] || '{}')) + tiny_mce_img.image.attach(to_blob) if description.gsub!("data-mce-token=\"#{tiny_mce_img_json['tokenId']}\"", "data-mce-token=\"#{Base62.encode(tiny_mce_img.id)}\"") else