Commit 7edcf42a authored by Kassio Borges's avatar Kassio Borges

Group Avatar API: ensure to send the remote filename

Changelog: fixed
MR: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/64650
parent e4161296
......@@ -14,6 +14,20 @@ module API
detail 'This feature was introduced in GitLab 14.0'
end
get ':id/avatar' do
avatar = user_group.avatar
not_found!('Avatar') if avatar.blank?
filename = File.basename(avatar.file.file)
header(
'Content-Disposition',
ActionDispatch::Http::ContentDisposition.format(
disposition: 'attachment',
filename: filename
)
)
present_carrierwave_file!(user_group.avatar)
end
end
......
......@@ -15,6 +15,8 @@ RSpec.describe API::GroupAvatar do
get api(avatar_path(group))
expect(response).to have_gitlab_http_status(:ok)
expect(response.headers['Content-Disposition'])
.to eq(%(attachment; filename="dk.png"; filename*=UTF-8''dk.png))
end
context 'when the group does not have avatar' do
......@@ -24,6 +26,8 @@ RSpec.describe API::GroupAvatar do
get api(avatar_path(group))
expect(response).to have_gitlab_http_status(:not_found)
expect(response.body)
.to eq(%({"message":"404 Avatar Not Found"}))
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment