BigW Consortium Gitlab

server_side.rb 718 Bytes
Newer Older
Douwe Maan committed
1 2 3 4 5
module BlobViewer
  module ServerSide
    extend ActiveSupport::Concern

    included do
6
      self.load_async = true
7 8
      self.collapse_limit = 2.megabytes
      self.size_limit = 5.megabytes
Douwe Maan committed
9
    end
10 11

    def prepare!
12
      blob.load_all_data!
13
    end
14 15

    def render_error
Douwe Maan committed
16 17 18 19
      # 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
Douwe Maan committed
20
      # `blob_raw_path` using AJAX.
Douwe Maan committed
21
      return :server_side_but_stored_externally if blob.stored_externally?
22 23 24

      super
    end
Douwe Maan committed
25 26
  end
end