diff options
Diffstat (limited to 'app/controllers/projects/raw_controller.rb')
-rw-r--r-- | app/controllers/projects/raw_controller.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/app/controllers/projects/raw_controller.rb b/app/controllers/projects/raw_controller.rb new file mode 100644 index 00000000000..0d35f373e9c --- /dev/null +++ b/app/controllers/projects/raw_controller.rb @@ -0,0 +1,25 @@ +# Controller for viewing a file's raw +class Projects::RawController < Projects::ApplicationController + include ExtractsPath + + # Authorize + before_filter :authorize_read_project! + before_filter :authorize_code_access! + before_filter :require_non_empty_project + + def show + @blob = Gitlab::Git::Blob.new(@repository, @commit.id, @ref, @path) + + if @blob.exists? + send_data( + @blob.data, + type: @blob.mime_type, + disposition: 'inline', + filename: @blob.name + ) + else + not_found! + end + end +end + |