From 433ef4513b434d97ea8716d6e7b60030f1607e96 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 18 Dec 2017 10:40:10 +1100 Subject: [PATCH] FEATURE: upload images and fonts in themes via hijack --- app/controllers/admin/themes_controller.rb | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/app/controllers/admin/themes_controller.rb b/app/controllers/admin/themes_controller.rb index 5416f10d500..b0f8d21f396 100644 --- a/app/controllers/admin/themes_controller.rb +++ b/app/controllers/admin/themes_controller.rb @@ -13,13 +13,16 @@ class Admin::ThemesController < Admin::AdminController def upload_asset path = params[:file].path - File.open(path) do |file| - filename = params[:file]&.original_filename || File.basename(path) - upload = UploadCreator.new(file, filename, for_theme: true).create_for(current_user.id) - if upload.errors.count > 0 - render_json_error upload - else - render json: { upload_id: upload.id }, status: :created + + hijack do + File.open(path) do |file| + filename = params[:file]&.original_filename || File.basename(path) + upload = UploadCreator.new(file, filename, for_theme: true).create_for(current_user.id) + if upload.errors.count > 0 + render_json_error upload + else + render json: { upload_id: upload.id }, status: :created + end end end end