Save liveview uploaded file to a custom tmp directory

Hello everyone,

I would like to save liveview file uploads to another directory than /tmp, for example /custom/tmp.

Is that possible?

Thanks for taking time

1 Like

Sorry for the question, I have been using many different syntax, and the last is working

But only after upgrading to Phoenix Liveview 1.1

    socket
    |> allow_upload(:medium,
      accept: ~w(.mp4),
      max_entries: 1,
      auto_upload: true,
      # Provide a limit, as the default is low
      max_file_size: @max_file_size,
      chunk_size: @chunk_size,
      # writer: {:temporary, dir: "/export/tmp"}
      # writer: fn _name, _entry, _socket -> {:temporary, dir: "/export/tmp"} end
      # writer: fn _name, _entry, _socket -> {KokoWeb.CustomWriter, level: :debug} end
      writer: fn _name, _entry, _socket -> {KokoWeb.CustomWriter, level: :debug, dir: "/export/tmp"} end
    )
2 Likes