Skip to content

Commit

Permalink
--amend
Browse files Browse the repository at this point in the history
  • Loading branch information
Krister Viirsaar committed Nov 20, 2024
1 parent 93a65cd commit cc706ed
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions lib/azure_storage/azure_file_share.ex
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,21 @@ defmodule AzureStorage.FileShare do
@spec get_file(Context.t(), String.t(), String.t(), String.t()) ::
{:ok, binary(), map()} | {:error, String.t()}
def get_file(%Context{service: "file"} = context, share, directory, filename) do
path =
[share, directory, filename]
|> Enum.reject(&(&1 in [nil, ""]))
|> Path.join()
cond do
is_nil(share) or share == "" ->
{:error, "missing_share"}

context
|> build(method: :get, path: path)
|> request(response_body: :full)
|> parse_body_headers_response()
is_nil(filename) or filename == "" ->
{:error, "missing_filename"}

true ->
path = Path.join([share, directory || "", filename])

context
|> build(method: :get, path: path)
|> request(response_body: :full)
|> parse_body_headers_response()
end
end

# helpers
Expand Down

0 comments on commit cc706ed

Please sign in to comment.