Skip to content

Commit

Permalink
Merge pull request #3945 from nulib/fix-api-url
Browse files Browse the repository at this point in the history
Fix download_url api path
  • Loading branch information
kdid authored May 3, 2024
2 parents a74b49e + 2a7fbd9 commit 9886a60
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions app/lib/meadow/data/file_sets.ex
Original file line number Diff line number Diff line change
Expand Up @@ -214,23 +214,20 @@ defmodule Meadow.Data.FileSets do
end

def derivative_key(file_set) do
Path.join([
"derivatives",
Pairtree.derivative_path(file_set.id)
])
Path.join([
"derivatives",
Pairtree.derivative_path(file_set.id)
])
end

def download_uri_for(%FileSet{id: id, role: %{id: "X"}}), do: download_uri(id)
def download_uri_for(%FileSet{id: id, role: %{id: "A"}}), do: download_uri(id)
def download_uri_for(_), do: nil

defp download_uri(id) do
with uri <- URI.parse(Application.get_env(:meadow, :dc_api) |> get_in([:v2, "base_url"])) do
uri
|> URI.merge("file-sets/" <> id <> "/download")
|> URI.to_string()
api_url = Application.get_env(:meadow, :dc_api) |> get_in([:v2, "base_url"])
"#{api_url}/file-sets/#{id}/download"
end
end

defp multi_update(file_set_updates) do
file_set_updates
Expand Down

0 comments on commit 9886a60

Please sign in to comment.