Skip to content

Instantly share code, notes, and snippets.

@grahamb
Forked from lukfugl/files_controller.diff
Last active May 4, 2018 18:49
Show Gist options
  • Save grahamb/95f85722c2bd6a1575a817964d9cb04b to your computer and use it in GitHub Desktop.
Save grahamb/95f85722c2bd6a1575a817964d9cb04b to your computer and use it in GitHub Desktop.
fix avatar upload for local storage
diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb
index eeaa0d3..fe0e7d9 100644
--- a/app/controllers/files_controller.rb
+++ b/app/controllers/files_controller.rb
@@ -763,7 +763,9 @@ class FilesController < ApplicationController
@attachment.uploaded_data = params[:file] || params[:attachment] && params[:attachment][:uploaded_data]
if @attachment.save
# for consistency with the s3 upload client flow, we redirect to the success url here to finish up
- redirect_to api_v1_files_create_success_url(@attachment, :uuid => @attachment.uuid, :on_duplicate => params[:on_duplicate], :quota_exemption => params[:quota_exemption])
+ includes = Array(params[:success_include])
+ includes << 'avatar' if @attachment.folder == @attachment.user&.profile_pics_folder
+ redirect_to api_v1_files_create_success_url(@attachment, :uuid => @attachment.uuid, :on_duplicate => params[:on_duplicate], :quota_exemption => params[:quota_exemption], :include => includes)
else
head :bad_request
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment