fix: Add blank check for file param in Import API (#3057)

This commit is contained in:
Murtaza Bagwala
2021-09-21 10:20:12 +05:30
committed by GitHub
parent b59e73b10b
commit c504067e2b
3 changed files with 20 additions and 0 deletions

View File

@@ -30,10 +30,13 @@ class Api::V1::Accounts::ContactsController < Api::V1::Accounts::BaseController
end
def import
render json: { error: I18n.t('errors.contacts.import.failed') }, status: :unprocessable_entity and return if params[:import_file].blank?
ActiveRecord::Base.transaction do
import = Current.account.data_imports.create!(data_type: 'contacts')
import.import_file.attach(params[:import_file])
end
head :ok
end