mirror of https://github.com/docusealco/docuseal
				
				
				
			
			You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							28 lines
						
					
					
						
							676 B
						
					
					
				
			
		
		
	
	
							28 lines
						
					
					
						
							676 B
						
					
					
				| # frozen_string_literal: true
 | |
| 
 | |
| module Api
 | |
|   class TemplatesDocumentsController < ApiBaseController
 | |
|     load_and_authorize_resource :template
 | |
| 
 | |
|     def create
 | |
|       return head :unprocessable_entity if params[:blobs].blank? && params[:files].blank?
 | |
| 
 | |
|       documents = Templates::CreateAttachments.call(@template, params)
 | |
| 
 | |
|       schema = documents.map do |doc|
 | |
|         { attachment_uuid: doc.uuid, name: doc.filename.base }
 | |
|       end
 | |
| 
 | |
|       render json: {
 | |
|         schema:,
 | |
|         documents: documents.as_json(
 | |
|           methods: [:metadata],
 | |
|           include: {
 | |
|             preview_images: { methods: %i[url metadata filename] }
 | |
|           }
 | |
|         )
 | |
|       }
 | |
|     end
 | |
|   end
 | |
| end
 |