2017-04-13 17:21:07 +00:00
|
|
|
module BlobViewer
|
|
|
|
module ServerSide
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
included do
|
2017-05-12 19:43:06 +00:00
|
|
|
self.load_async = true
|
2017-05-26 23:27:30 +00:00
|
|
|
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!
|
2017-06-06 21:20:24 +00:00
|
|
|
blob.load_all_data!
|
2017-05-08 23:50:23 +00:00
|
|
|
end
|
2017-05-12 19:43:06 +00:00
|
|
|
|
|
|
|
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?
|
2017-05-12 19:43:06 +00:00
|
|
|
|
|
|
|
super
|
|
|
|
end
|
2017-04-13 17:21:07 +00:00
|
|
|
end
|
|
|
|
end
|