2019-03-11 20:43:50 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-04-19 15:13:16 +08:00
|
|
|
class TinyMceAssetsController < ApplicationController
|
|
|
|
|
|
|
|
def create
|
2017-04-21 22:09:04 +08:00
|
|
|
image = params.fetch(:file) { render_404 }
|
2017-04-25 19:44:31 +08:00
|
|
|
tiny_img = TinyMceAsset.new(image: image,
|
2019-03-11 20:43:50 +08:00
|
|
|
team_id: current_team.id,
|
|
|
|
saved: false)
|
2017-04-21 22:09:04 +08:00
|
|
|
if tiny_img.save
|
|
|
|
render json: {
|
2017-04-24 22:22:25 +08:00
|
|
|
image: {
|
|
|
|
url: view_context.image_url(tiny_img.url(:large)),
|
|
|
|
token: Base62.encode(tiny_img.id)
|
|
|
|
}
|
2017-04-21 22:09:04 +08:00
|
|
|
}, content_type: 'text/html'
|
|
|
|
else
|
2017-04-24 22:22:25 +08:00
|
|
|
render json: {
|
|
|
|
error: tiny_img.errors.full_messages
|
|
|
|
}, status: :unprocessable_entity
|
2017-04-21 22:09:04 +08:00
|
|
|
end
|
2017-04-19 15:13:16 +08:00
|
|
|
end
|
2017-04-19 23:22:57 +08:00
|
|
|
|
2017-04-19 15:13:16 +08:00
|
|
|
end
|