gitlab-org--gitlab-foss/app/controllers/raw_controller.rb

26 lines
535 B
Ruby
Raw Normal View History

# Controller for viewing a file's raw
class RawController < ProjectResourceController
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