Merge pull request #2132 from aignatov-bio/ai-sci-3676-fix-tinymce-import-from-eln

Fix TinyMCE import from .eln [SCI-3972]
This commit is contained in:
aignatov-bio 2019-10-07 16:48:58 +02:00 committed by GitHub
commit 4439ffce6c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -157,10 +157,11 @@ module ProtocolsImporter
# Decode the file bytes # Decode the file bytes
file = StringIO.new(Base64.decode64(tiny_mce_img_json['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'], filename: tiny_mce_img_json['fileName'],
content_type: tiny_mce_img_json['fileType'], content_type: tiny_mce_img_json['fileType'],
metadata: JSON.parse(tiny_mce_img_json['fileMetadata'] || '{}')) 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']}\"", if description.gsub!("data-mce-token=\"#{tiny_mce_img_json['tokenId']}\"",
"data-mce-token=\"#{Base62.encode(tiny_mce_img.id)}\"") "data-mce-token=\"#{Base62.encode(tiny_mce_img.id)}\"")
else else