Storage.Controller (PhoenixContribStorage v0.1.0)

View Source

Phoenix controller for serving Storage files.

Add this to your router:

get "/storage/:key", Storage.Controller, :serve

Or for more control:

scope "/storage" do
  get "/:key", Storage.Controller, :serve
  get "/:key/:filename", Storage.Controller, :serve_with_filename
end

Summary

Functions

Serves a blob as an attachment (forces download).

Serves a file by its storage key.

Serves a blob with appropriate headers.

Serves a file by its storage key with a specific filename in the URL. This is useful for SEO and user-friendly URLs.

Functions

download(conn, map)

Serves a blob as an attachment (forces download).

serve(conn, map)

Serves a file by its storage key.

serve_blob(conn, blob)

Serves a blob with appropriate headers.

serve_with_filename(conn, map)

Serves a file by its storage key with a specific filename in the URL. This is useful for SEO and user-friendly URLs.