Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jeroenvisser101/content_disposition
A helper package for Elixir to generate Content-Disposition values
https://github.com/jeroenvisser101/content_disposition
content-disposition elixir
Last synced: 19 days ago
JSON representation
A helper package for Elixir to generate Content-Disposition values
- Host: GitHub
- URL: https://github.com/jeroenvisser101/content_disposition
- Owner: jeroenvisser101
- License: mit
- Created: 2021-07-09T16:35:11.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-08-01T02:37:23.000Z (over 3 years ago)
- Last Synced: 2025-01-02T23:32:26.280Z (22 days ago)
- Topics: content-disposition, elixir
- Language: Elixir
- Homepage: https://hexdocs.pm/content_disposition
- Size: 9.77 KB
- Stars: 3
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ContentDisposition
[Online documentation](https://hexdocs.pm/content_disposition) | [Hex.pm](https://hex.pm/packages/content_disposition)
`ContentDisposition` helps properly formatting Content-Disposition headers.
Inspired by Ruby's [`content_disposition`](https://github.com/shrinerb/content_disposition) gem,
this package formats a given disposition and optional filename to an acceptable value for the
`Content-Disposition` header. It takes care of encoding, escaping and adds an ASCII fallback.## Examples
```elixir
# Without filename
iex> ContentDisposition.format(disposition: :inline)
"inline"# With a filename, and disposition as a string
iex> ContentDisposition.format(disposition: "inline", filename: "kitten.jpg")
"inline; filename=\"kitten.jpg\"; filename*=UTF-8''kitten.jpg"# With a UTF-8 filename as attachment
iex> ContentDisposition.format(disposition: :attachment, filename: "kïttéñ.jpg")
"attachment; filename=\"k%3Ftt%3F%3F.jpg\"; filename*=UTF-8''k%C3%AFtt%C3%A9%C3%B1.jpg"
```## Installation
Add `content_disposition` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[{:content_disposition, "~> 1.0.0"}]
end
```## License
This library is MIT licensed. See the
[LICENSE](https://raw.github.com/jeroenvisser101/content_disposition/main/LICENSE)
file in this repository for details.