Skip to content

Commit

Permalink
Changed content type
Browse files Browse the repository at this point in the history
  • Loading branch information
mellelieuwes committed Nov 23, 2023
1 parent dc1ffa1 commit 1a3f15c
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion core/systems/feldspar/s3.ex
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ defmodule Systems.Feldspar.S3 do
Access.fetch!(settings, :bucket),
"#{object_key(target)}/#{name}",
data,
content_type: "text/html"
content_type: content_type(name)
)
|> backend().request!()
else
Expand Down Expand Up @@ -82,4 +82,22 @@ defmodule Systems.Feldspar.S3 do
# Allow mocking
Access.get(s3_settings(), :s3_backend, ExAws)
end

defp content_type("html"), do: "text/html"
defp content_type("js"), do: "text/javascript"
defp content_type("css"), do: "text/css"
defp content_type("svg"), do: "image/svg+xml"
defp content_type("ico"), do: "image/x-icon"
defp content_type("whl"), do: " application/zip"
defp content_type("json"), do: "application/json"
defp content_type("ts"), do: "application/typescript"
defp content_type("tsx"), do: "application/typescript"
defp content_type(nil), do: "text/html"

defp content_type(name) do
name
|> String.split(name, ".")
|> List.last()
|> content_type()
end
end

0 comments on commit 1a3f15c

Please sign in to comment.