Module: Card::Set::Type::File::FileFormat

Extended by:
AbstractFormat
Included in:
Image::FileFormat
Defined in:
card/tmpsets/set/mod014-card-mod-carrierwave/type/file.rb,
card/tmpsets/set/mod013-card-mod-carrierwave/type/file.rb

Instance Method Summary collapse

Instance Method Details

#args_for_send_fileObject



67
68
69
70
71
72
73
# File 'card/tmpsets/set/mod014-card-mod-carrierwave/type/file.rb', line 67

def args_for_send_file
  file = selected_version
  [file.path, { type: file.content_type,
                filename:  "#{card.name.safe_key}#{file.extension}",
                x_sendfile: true,
                disposition: (params[:format] == "file" ? "attachment" : "inline") }]
end

#set_response_headersObject



75
76
77
78
79
80
81
# File 'card/tmpsets/set/mod014-card-mod-carrierwave/type/file.rb', line 75

def set_response_headers
  return unless params[:explicit_file] && (response = controller&.response)
  response.headers["Expires"] = 1.year.from_now.httpdate
  # currently using default "private", because proxy servers could block
  # needed permission checks
  # r.headers["Cache-Control"] = "public"
end

#view: coreObject

NOCACHE because returns send_file args. not in love with this…



58
59
60
61
62
63
64
65
# File 'card/tmpsets/set/mod014-card-mod-carrierwave/type/file.rb', line 58

view :core, cache: :never do
  # this means we only support known formats.  dislike.
  attachment_format = card.attachment_format(params[:format])
  return _render_not_found unless attachment_format
  return card.format(:html).render_core if card.remote_storage?
  set_response_headers
  args_for_send_file
end