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

Extended by:
AbstractFormat
Included in:
Image::FileFormat
Defined in:
platypus/tmp/set/gem-defaults/mod016-carrierwave/type/file.rb

Instance Method Summary collapse

Instance Method Details

#args_for_send_fileObject



79
80
81
82
83
84
85
# File 'platypus/tmp/set/gem-defaults/mod016-carrierwave/type/file.rb', line 79

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



87
88
89
90
91
92
93
94
# File 'platypus/tmp/set/gem-defaults/mod016-carrierwave/type/file.rb', line 87

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…



69
70
71
72
73
74
75
76
77
# File 'platypus/tmp/set/gem-defaults/mod016-carrierwave/type/file.rb', line 69

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