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