module
ActiveStorage::ContentDisposition
Overview
Builds Content-Disposition header values the way Rails does.
Both the traditional filename parameter and the RFC 5987 filename* parameter are emitted, so
the produced value matches what Rails sends byte for byte for ASCII filenames.
https://github.com/rails/rails/blob/v8.1.3/actionpack/lib/action_dispatch/http/content_disposition.rb
Defined in:
active_storage/content_disposition.crConstant Summary
-
RFC_5987_ESCAPED_CHAR =
/[^A-Za-z0-9!#$&+.^_`|~-]/ -
Characters escaped in the RFC 5987
filename*parameter. -
TRADITIONAL_ESCAPED_CHAR =
/[^ A-Za-z0-9!#$+.^_`|~-]/ -
Characters escaped in the traditional
filenameparameter.
Class Method Summary
-
.ascii_filename(filename : String) : String
Returns the traditional
filenameparameter. -
.format(disposition : String, filename : String | Nil) : String
Returns the
Content-Dispositionvalue for the passed disposition and filename. -
.utf8_filename(filename : String) : String
Returns the RFC 5987
filename*parameter.
Class Method Detail
Returns the traditional filename parameter.
Unlike Rails this does not transliterate the filename first (there is no I18n.transliterate
equivalent here), so non-ASCII characters are percent escaped instead of being folded to their
ASCII lookalike. Clients that understand filename* are unaffected.
Returns the Content-Disposition value for the passed disposition and filename.
ActiveStorage::ContentDisposition.format(disposition: "inline", filename: "racecar.jpg")
# => %(inline; filename="racecar.jpg"; filename*=UTF-8''racecar.jpg)