add ck editor file upload endpoint

This commit is contained in:
João Geonizeli
2022-07-21 10:28:07 -03:00
parent ed1ed73ed7
commit 3928da4577
8 changed files with 326 additions and 39 deletions

View File

@@ -0,0 +1,14 @@
class CkEditorUploadsController < ApplicationController
def create
@upload = CkEditorUpload.new(attachment: params[:attachment])
if @upload.save!
render(json: {
uploaded: true,
url: rails_blob_url(@upload.attachment, only_path: false),
})
else
render(json: { uploaded: false })
end
end
end

View File

@@ -0,0 +1,11 @@
# == Schema Information
#
# Table name: ck_editor_uploads
#
# id :bigint not null, primary key
# created_at :datetime not null
# updated_at :datetime not null
#
class CkEditorUpload < ApplicationRecord
has_one_attached :attachment
end