summaryrefslogtreecommitdiff
path: root/app/controllers/projects/avatars_controller.rb
blob: b90a95c3aab32f388af150f7d4ba50154242dcca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
class Projects::AvatarsController < Projects::ApplicationController
  layout 'project'

  before_filter :project

  def show
    @blob = @project.repository.blob_at_branch('master', @project.avatar_in_git)
    if @blob
      headers['X-Content-Type-Options'] = 'nosniff'
      send_data(
        @blob.data,
        type: @blob.mime_type,
        disposition: 'inline',
        filename: @blob.name
      )
    else
      not_found!
    end
  end

  def destroy
    @project.remove_avatar!

    @project.save
    @project.reset_events_cache

    redirect_to edit_namespace_project_path(@project.namespace, @project)
  end
end