2014-01-25 12:15:44 -05:00
|
|
|
class Projects::AvatarsController < Projects::ApplicationController
|
2016-02-24 05:53:30 -05:00
|
|
|
include BlobHelper
|
|
|
|
|
2016-03-20 16:03:53 -04:00
|
|
|
before_action :authorize_admin_project!, only: [:destroy]
|
2014-01-25 12:15:44 -05:00
|
|
|
|
|
|
|
def show
|
2016-02-02 09:06:14 -05:00
|
|
|
@blob = @repository.blob_at_branch('master', @project.avatar_in_git)
|
2014-01-25 12:15:44 -05:00
|
|
|
if @blob
|
|
|
|
headers['X-Content-Type-Options'] = 'nosniff'
|
2016-03-07 08:27:53 -05:00
|
|
|
|
|
|
|
return if cached_blob?
|
|
|
|
|
2016-02-02 09:06:14 -05:00
|
|
|
headers.store(*Gitlab::Workhorse.send_git_blob(@repository, @blob))
|
2016-01-28 12:04:46 -05:00
|
|
|
headers['Content-Disposition'] = 'inline'
|
2016-02-24 05:53:30 -05:00
|
|
|
headers['Content-Type'] = safe_content_type(@blob)
|
2016-02-01 06:01:13 -05:00
|
|
|
head :ok # 'render nothing: true' messes up the Content-Type
|
2014-01-25 12:15:44 -05:00
|
|
|
else
|
2015-10-09 13:07:29 -04:00
|
|
|
render_404
|
2014-01-25 12:15:44 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
@project.remove_avatar!
|
|
|
|
|
|
|
|
@project.save
|
|
|
|
@project.reset_events_cache
|
|
|
|
|
2015-02-25 22:34:16 -05:00
|
|
|
redirect_to edit_project_path(@project)
|
2014-01-25 12:15:44 -05:00
|
|
|
end
|
|
|
|
end
|