Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/api/group_avatar.rb')
-rw-r--r--lib/api/group_avatar.rb22
1 files changed, 17 insertions, 5 deletions
diff --git a/lib/api/group_avatar.rb b/lib/api/group_avatar.rb
index ddf6787f913..9063040c763 100644
--- a/lib/api/group_avatar.rb
+++ b/lib/api/group_avatar.rb
@@ -6,15 +6,27 @@ module API
feature_category :subgroups
- resource :groups do
+ params do
+ requires :id, type: String, desc: 'The ID of a group'
+ end
+ resource :groups, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
desc 'Download the group avatar' do
detail 'This feature was introduced in GitLab 14.0'
end
- params do
- requires :id, type: String, desc: 'The group id'
- end
get ':id/avatar' do
- present_carrierwave_file!(user_group.avatar)
+ avatar = user_group.avatar
+
+ not_found!('Avatar') if avatar.blank?
+
+ header(
+ 'Content-Disposition',
+ ActionDispatch::Http::ContentDisposition.format(
+ disposition: 'attachment',
+ filename: avatar.filename
+ )
+ )
+
+ present_carrierwave_file!(avatar)
end
end
end