mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-27 10:14:17 +08:00
Fix protocol copy, add metadata to assets
This commit is contained in:
parent
c78ab50e0c
commit
b5a35f583a
3 changed files with 13 additions and 3 deletions
|
@ -73,7 +73,10 @@ module TinyMceImages
|
|||
|
||||
tiny_img_clone.transaction do
|
||||
tiny_img_clone.save!
|
||||
tiny_img_clone.image.attach(io: tiny_img.image.open, filename: tiny_img.image.filename.to_s)
|
||||
tiny_img_clone.image.attach(io: StringIO.new(tiny_img.image.download),
|
||||
filename: tiny_img.file_name,
|
||||
content_type: tiny_img.content_type,
|
||||
metadata: tiny_img.image.metadata)
|
||||
end
|
||||
|
||||
target.tiny_mce_assets << tiny_img_clone
|
||||
|
@ -96,7 +99,7 @@ module TinyMceImages
|
|||
|
||||
next if asset && asset.object == self && asset.team_id != asset_team_id
|
||||
|
||||
new_image = asset.image
|
||||
new_image = StringIO.new(asset.image.download)
|
||||
new_image_filename = new_image.file_name
|
||||
else
|
||||
# We need implement size and type checks here
|
||||
|
|
|
@ -294,6 +294,10 @@ class Protocol < ApplicationRecord
|
|||
step.assets.each do |asset|
|
||||
asset2 = asset.dup
|
||||
asset2.save!
|
||||
asset2.file.attach(io: StringIO.new(asset.file.download),
|
||||
filename: asset.file_name,
|
||||
content_type: asset.content_type,
|
||||
metadata: asset.file.metadata)
|
||||
step2.assets << asset2
|
||||
assets_to_clone << [asset.id, asset2.id]
|
||||
end
|
||||
|
|
|
@ -170,7 +170,10 @@ class TinyMceAsset < ApplicationRecord
|
|||
|
||||
tiny_img_clone.transaction do
|
||||
tiny_img_clone.save!
|
||||
tiny_img_clone.image.attach(io: image.download, filename: image.filename.sanitized)
|
||||
tiny_img_clone.image.attach(io: StringIO.new(image.download),
|
||||
filename: file_name,
|
||||
content_type: content_type,
|
||||
metadta: image.metadata)
|
||||
end
|
||||
|
||||
return false unless tiny_img_clone.persisted?
|
||||
|
|
Loading…
Reference in a new issue