Files
docuseal/app/controllers/api/attachments_controller.rb
T

22 lines
555 B
Ruby
Raw Normal View History

2023-05-21 17:59:36 +03:00
# frozen_string_literal: true
module Api
class AttachmentsController < ApiBaseController
skip_before_action :authenticate_user!
def create
2023-06-18 16:30:35 +03:00
submitter = Submitter.find_by!(slug: params[:submitter_slug])
2023-05-28 23:20:48 +03:00
2023-05-21 17:59:36 +03:00
blob = ActiveStorage::Blob.find_signed(params[:blob_signed_id])
attachment = ActiveStorage::Attachment.create!(
blob:,
name: params[:name],
2023-06-13 00:29:07 +03:00
record: submitter || current_account
2023-05-21 17:59:36 +03:00
)
render json: attachment.as_json(only: %i[uuid], methods: %i[url filename content_type])
end
end
end