   use BeerNapkin.Web, :controller
   plug :authenticate
   alias BeerNapkin.Napkin
-  @s3_host Application.get_env(:beer_napkin, :s3_host)
-  @s3_bucket Application.get_env(:beer_napkin, :s3_bucket)
 
   def new(conn, _params) do
     changeset = Napkin.changeset(%Napkin{})

    image_key = save_image(image, token)
    user_napkin_params = Map.merge(napkin_params, %{
      "user_id" => conn.assigns.current_user.id,
      "image_url" => "#{@s3_host}/#{@s3_bucket}/#{image_key}",
      "image_key" => image_key
    })


      {_title, _url} -> napkin_params
    end
  end

  defp bucket do
    Application.get_env(:beer_napkin, :s3_bucket)
  end

  defp s3_host do
    Application.get_env(:beer_napkin, :s3_host)
  end
end
