Skip to content

Instantly share code, notes, and snippets.

@myobie
Last active April 15, 2021 09:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save myobie/509e9468363521d334e38c3707cc1a86 to your computer and use it in GitHub Desktop.
Save myobie/509e9468363521d334e38c3707cc1a86 to your computer and use it in GitHub Desktop.
A pipeline for proxying large file uploads
defmodule AppWeb.Router do
use AppWeb, :router
pipeline :browser do
plug Plug.Parsers,
parsers: [:urlencoded, :multipart, :json],
pass: ["*/*"],
json_decoder: Phoenix.json_library()
plug Plug.MethodOverride
plug Plug.Head
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_flash
plug :protect_from_forgery
plug :put_secure_browser_headers
end
pipeline :api do
plug Plug.Parsers,
parsers: [:multipart, :json],
pass: ["*/*"],
json_decoder: Phoenix.json_library()
plug Plug.Head
plug :accepts, ["json"]
end
pipeline :binary do
# NOTE: It is important that this pipeline never include
# Plug.Parsers or it will spool every file to disk
plug :accepts, ["special-binary-v1"]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment