@@ -49,6 +49,10 @@ if Code.ensure_loaded?(Req) do
4949 (default: `"2020-12-06"`)
5050 - `:signed_protocol` - SAS protocol restriction. Defaults to `"https"`, or
5151 `"https,http"` for `http://` endpoints
52+ - `:decode_body` - whether `download/2` runs Req's content-type response
53+ decoding (JSON → map, CSV → rows, gzip → unzipped, etc.). Defaults to
54+ `true` to match Req's own default; pass `false` when you need the raw
55+ uploaded bytes.
5256
5357 ## Azure setup
5458
@@ -109,7 +113,8 @@ if Code.ensure_loaded?(Req) do
109113 expires_in: [ type: :integer ] ,
110114 direct_upload_expires_in: [ type: :integer ] ,
111115 service_version: [ type: :string ] ,
112- signed_protocol: [ type: :string ]
116+ signed_protocol: [ type: :string ] ,
117+ decode_body: [ type: :boolean ]
113118 ]
114119 end
115120
@@ -148,8 +153,11 @@ if Code.ensure_loaded?(Req) do
148153 def download ( key , % AshStorage.Service.Context { } = ctx ) do
149154 full_key = prefixed_key ( key , ctx )
150155
156+ decode_body? = Keyword . get ( ctx . service_opts , :decode_body , true )
157+
151158 with { :ok , url } <- signed_blob_url ( full_key , ctx , permissions: "r" , expires_in: 900 ) ,
152- { :ok , % { status: 200 , body: body } } <- Req . get ( url , headers: base_headers ( ctx ) ) ,
159+ { :ok , % { status: 200 , body: body } } <-
160+ Req . get ( url , headers: base_headers ( ctx ) , decode_body: decode_body? ) ,
153161 :ok <- verify_md5 ( body , ctx . expected_md5 ) do
154162 { :ok , body }
155163 else
0 commit comments