Skip to content

Instantly share code, notes, and snippets.

@hfabre
hfabre / upload_live.ex
Created June 17, 2024 15:54 — forked from nshafer/upload_live.ex
Process uploaded file
def handle_event("import", _params, socket) do
results =
consume_uploaded_entries(socket, :import, fn %{path: path}, _entry ->
temp_dir = Briefly.create!(type: :directory)
csv_file = Path.join(temp_dir, "import.csv")
# Attempt to create a new hard link to the file
case File.ln(path, csv_file) do
:ok ->
{:ok, csv_file}