Skip to content

Commit f203781

Browse files
authored
fix: adjust content-type header in Fetcher.Adapter.Finch.upload/3 (#76)
1 parent 4bf2861 commit f203781

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

lib/supabase/fetcher/adapter/finch.ex

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,20 @@ defmodule Supabase.Fetcher.Adapter.Finch do
124124

125125
@impl true
126126
def upload(%Request{} = b, file, opts \\ []) do
127-
mime_type = MIME.from_path(file)
128127
body_stream = File.stream!(file, 2048)
129128
%File.Stat{size: content_length} = File.stat!(file)
130-
content_headers = [{"content-length", to_string(content_length)}, {"content-type", mime_type}]
129+
130+
# Only use MIME.from_path if content-type is not already set
131+
content_type =
132+
case Supabase.Fetcher.Request.get_header(b, "content-type") do
133+
nil -> MIME.from_path(file)
134+
existing -> existing
135+
end
136+
137+
content_headers = [
138+
{"content-length", to_string(content_length)},
139+
{"content-type", content_type}
140+
]
131141

132142
b
133143
|> with_body({:stream, body_stream})

0 commit comments

Comments
 (0)