gitlab-org--gitlab-foss/app/models/blob_viewer/server_side.rb

29 lines
749 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2017-04-13 17:21:07 +00:00
module BlobViewer
module ServerSide
extend ActiveSupport::Concern
included do
self.load_async = true
self.collapse_limit = 2.megabytes
self.size_limit = 5.megabytes
2017-04-13 17:21:07 +00:00
end
2017-05-08 23:50:23 +00:00
def prepare!
blob.load_all_data!
2017-05-08 23:50:23 +00:00
end
def render_error
2017-06-06 21:28:06 +00:00
# Files that are not stored in the repository, like LFS files and
# build artifacts, can only be rendered using a client-side viewer,
# since we do not want to read large amounts of data into memory on the
# server side. Client-side viewers use JS and can fetch the file from
2017-08-03 12:29:35 +00:00
# `blob_raw_path` using AJAX.
2017-06-06 21:28:06 +00:00
return :server_side_but_stored_externally if blob.stored_externally?
super
end
2017-04-13 17:21:07 +00:00
end
end