add ck editor file upload endpoint
This commit is contained in:
14
app/controllers/ck_editor_uploads_controller.rb
Normal file
14
app/controllers/ck_editor_uploads_controller.rb
Normal 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
|
||||
11
app/models/ck_editor_upload.rb
Normal file
11
app/models/ck_editor_upload.rb
Normal 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
|
||||
Reference in New Issue
Block a user