aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--web/controllers/audio_file_controller.ex21
1 files changed, 13 insertions, 8 deletions
diff --git a/web/controllers/audio_file_controller.ex b/web/controllers/audio_file_controller.ex
index c32a7f8..dbcb6f9 100644
--- a/web/controllers/audio_file_controller.ex
+++ b/web/controllers/audio_file_controller.ex
@@ -13,18 +13,16 @@ defmodule TheTranscriberBackend.AudioFileController do
render(conn, "new.html", changeset: changeset)
end
- def create(conn, %{"audio_file" => audio_file_params}) do
- if upload = audio_file_params["audio_path"] do
- extension = Path.extname(upload.filename)
- path = "/media/phoenix_test/#{upload.filename}"
- File.cp(upload.path, path)
- end
+ def create(conn, %{"audio_file" => %{"audio_duration" => audio_duration, "audio_path" => upload, "transcription_file_path" => transcription_file_path}}) do
+
+ path = "/media/phoenix_test/#{upload.filename}"
+ File.cp(upload.path, path)
# "Non-elixir" way of doing things
changeset = AudioFile.changeset(%AudioFile{},
%{audio_path: path,
- transcription_file_path: audio_file_params["transcription_file_path"],
- audio_duration: audio_file_params["audio_duration"]})
+ transcription_file_path: transcription_file_path,
+ audio_duration: audio_duration})
IO.inspect changeset
@@ -38,6 +36,13 @@ defmodule TheTranscriberBackend.AudioFileController do
end
end
+
+
+ def create(conn, %{"audio_file" => %{"audio_duration" => audio_duration, "transcription_file_path" => transcription_file_path}}) do
+
+ ## Do something here if no file has been uploaded
+ end
+
def show(conn, %{"id" => id}) do
audio_file = Repo.get!(AudioFile, id)
render(conn, "show.html", audio_file: audio_file)