FIX: Add new content type for theme/component

When uploading a theme/component, depending on the extension of the
file and the OS/Browser being used, the content type might differ.

This adds the "application/x-zip-compressed" content type that is being
sent by most Browsers on latest Windows when uploading a .zip file.
This commit is contained in:
Régis Hanol 2019-12-11 19:50:23 +01:00
parent 2f8a25b2d5
commit 278d70f3eb
1 changed files with 8 additions and 1 deletions

View File

@ -51,6 +51,13 @@ class Admin::ThemesController < Admin::AdminController
}
end
THEME_CONTENT_TYPES ||= %w{
application/gzip
application/x-gzip
application/x-zip-compressed
application/zip
}
def import
@theme = nil
if params[:theme] && params[:theme].content_type == "application/json"
@ -98,7 +105,7 @@ class Admin::ThemesController < Admin::AdminController
rescue RemoteTheme::ImportError => e
render_json_error e.message
end
elsif params[:bundle] || (params[:theme] && ["application/x-gzip", "application/gzip", "application/zip"].include?(params[:theme].content_type))
elsif params[:bundle] || (params[:theme] && THEME_CONTENT_TYPES.include?(params[:theme].content_type))
# params[:bundle] used by theme CLI. params[:theme] used by admin UI
bundle = params[:bundle] || params[:theme]
theme_id = params[:theme_id]