How to change storage_dir for binary? [ARC]

I am using Arc with Phoenix Channels and an external js client. I want to set the path based on room id.
E.g: room:5 => save file in uploads/rooms/5/

  • Inside channel.ex
 def handle_in("new_msg", params, socket) do

"room:" <> room  = socket.topic
 file_params = %{filename: params["filename"], binary: params["body"]}

        |> decode_binary()


defp decode_binary(params) do
    Map.put(params, :binary, Base.decode64!(params.binary))

  • Inside file_uploader.ex

  use Arc.Definition

  @versions [:original]
  def __storage, do: Arc.Storage.Local

  def storage_dir(version, {file, room_id}) do

1 Like

Since storage_dir receives scope, you need to define function like this
def storage_dir(version, {file, scope}) do
and inside it, search the proper key through IO.inspect scope.