I have DropZone.js set up to accept an uploaded file.
<div class="container">
<%= form_for @conn, Routes.admin_upload_path(@conn, :create, []), [data: [turbolinks: false], multipart: true, class: " dropzone dz-clickable rounded-lg h-1/2 bg-gray-200 justify-center my-5 flex flex-wrap", id: "mydropzone", name: "mydropzone"], fn f-> %>
<div class="dropzone-previews"></div>
<% end %>
</div>
Once uploaded, the file properly gets sent to the correct action:
def create(conn, %{"upload" => upload} = params) do
# Temp use for testing
csv_sha256 = "1fa7cfa1068a21894ebdab8edfd074453571c0d5520223380d8c44c633b4e288"
conn
|> put_flash(:info, "file uploaded correctly")
|> redirect(to: Routes.admin_upload_path(conn, :show, csv_sha256))
end
def show(conn, %{"csv_sha256" => csv_sha256} = params) do
shipments = App.list_shipments_by_csv_sha256()
render(conn, "show.html")
end
The problem I am facing is that I am unable to redirect or render once I’ve reached the create action. I’ve been able to solve this problem in other projects by using the DropZone event “queueComplete”:
queuecomplete: function queuecomplete() {
let dropzone = document.getElementById("mydropzone");
window.location.href = dropzone.action;
},
I am unable to use this workout around this time because instead of just returning to an index page, I need to go to a page using a specific identifier. If anyone has an idea that can point me in the right direction that would be great. Thanks.`