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

27 lines
718 B
Ruby
Raw Normal View History

2017-04-13 13:21:07 -04: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 13:21:07 -04:00
end
2017-05-08 19:50:23 -04:00
def prepare!
blob.load_all_data!
2017-05-08 19:50:23 -04:00
end
def render_error
2017-06-06 17:28:06 -04: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 08:29:35 -04:00
# `blob_raw_path` using AJAX.
2017-06-06 17:28:06 -04:00
return :server_side_but_stored_externally if blob.stored_externally?
super
end
2017-04-13 13:21:07 -04:00
end
end