mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 07:53:49 +08:00
FEATURE: Uppy image uploader with UppyUploadMixin (#13656)
This PR adds the first use of Uppy in our codebase, hidden behind a enable_experimental_image_uploader site setting. When the setting is enabled only the user card background uploader will use the new uppy-image-uploader component added in this PR. I've introduced an UppyUpload mixin that has feature parity with the existing Upload mixin, and improves it slightly to deal with multiple/single file distinctions and validations better. For now, this just supports the XHRUpload plugin for uppy, which keeps our existing POST to /uploads.json.
This commit is contained in:
@ -16,8 +16,12 @@ class UploadsController < ApplicationController
|
||||
# capture current user for block later on
|
||||
me = current_user
|
||||
|
||||
params.permit(:type, :upload_type)
|
||||
if params[:type].blank? && params[:upload_type].blank?
|
||||
raise Discourse::InvalidParameters
|
||||
end
|
||||
# 50 characters ought to be enough for the upload type
|
||||
type = params.require(:type).parameterize(separator: "_")[0..50]
|
||||
type = (params[:upload_type].presence || params[:type].presence).parameterize(separator: "_")[0..50]
|
||||
|
||||
if type == "avatar" && !me.admin? && (SiteSetting.discourse_connect_overrides_avatar || !SiteSetting.allow_uploaded_avatars)
|
||||
return render json: failed_json, status: 422
|
||||
|
Reference in New Issue
Block a user