This commit is contained in:
2025-11-07 13:34:32 -08:00
commit 1e8c5a972b
436 changed files with 11000 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
class ActionText::Markdown::UploadsController < ApplicationController
allow_unauthenticated_access only: :show
before_action do
ActiveStorage::Current.url_options = { protocol: request.protocol, host: request.host, port: request.port }
end
def create
@record = GlobalID::Locator.locate_signed params[:record_gid]
@markdown = @record.safe_markdown_attribute params[:attribute_name]
@markdown.uploads.attach [ params[:file] ]
@markdown.save!
@upload = @markdown.uploads.attachments.last
render :create, status: :created, formats: :json
end
def show
@attachment = ActiveStorage::Attachment.find_by! slug: "#{params[:slug]}.#{params[:format]}"
expires_in 1.year, public: true
redirect_to @attachment.url
end
end