mirror of
https://github.com/docusealco/docuseal.git
synced 2026-06-23 04:10:11 +00:00
32 lines
731 B
Ruby
32 lines
731 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Api
|
|
class FlowsDocumentsController < ApiBaseController
|
|
def create
|
|
@flow = current_account.flows.find(params[:flow_id])
|
|
|
|
documents =
|
|
params[:blobs].map do |blob|
|
|
blob = ActiveStorage::Blob.find_signed(blob[:signed_id])
|
|
|
|
document = @flow.documents.create!(blob:)
|
|
|
|
Flows::ProcessDocument.call(document)
|
|
end
|
|
|
|
schema = documents.map do |doc|
|
|
{ attachment_uuid: doc.uuid, name: doc.filename.base }
|
|
end
|
|
|
|
render json: {
|
|
schema:,
|
|
documents: documents.as_json(
|
|
include: {
|
|
preview_images: { methods: %i[url metadata filename] }
|
|
}
|
|
)
|
|
}
|
|
end
|
|
end
|
|
end
|