2021-06-09 11:10:05 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module API
|
|
|
|
class GroupAvatar < ::API::Base
|
|
|
|
helpers Helpers::GroupsHelpers
|
|
|
|
|
|
|
|
feature_category :subgroups
|
|
|
|
|
2021-06-21 02:10:13 -04:00
|
|
|
params do
|
|
|
|
requires :id, type: String, desc: 'The ID of a group'
|
|
|
|
end
|
|
|
|
resource :groups, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
2021-06-09 11:10:05 -04:00
|
|
|
desc 'Download the group avatar' do
|
|
|
|
detail 'This feature was introduced in GitLab 14.0'
|
|
|
|
end
|
|
|
|
get ':id/avatar' do
|
2021-06-23 14:07:10 -04:00
|
|
|
avatar = user_group.avatar
|
|
|
|
|
|
|
|
not_found!('Avatar') if avatar.blank?
|
|
|
|
|
|
|
|
header(
|
|
|
|
'Content-Disposition',
|
|
|
|
ActionDispatch::Http::ContentDisposition.format(
|
|
|
|
disposition: 'attachment',
|
2021-06-29 23:07:30 -04:00
|
|
|
filename: avatar.filename
|
2021-06-23 14:07:10 -04:00
|
|
|
)
|
|
|
|
)
|
|
|
|
|
2021-06-29 23:07:30 -04:00
|
|
|
present_carrierwave_file!(avatar)
|
2021-06-09 11:10:05 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|