Form submission with file input with turbo drive


I have a form with a file input. The file get’s attached in a stimulus controller via a DataTransfer instance and the form submitted by calling requestSubmit(). Like this, turbo takes care of the ajax form submission and the response handling (including triggering all the necessary turbo events).

let container = new DataTransfer();
this.fileInputTarget.files = container.files;

The DataTransfer constructor is not available on iOS < 14.5. As workaround, I can create a FormData instance from the form, attach the file to the formdata instance and submit it manually via fetch. I can then manually replace the body with the html from the fetch response, but need to somehow manually trigger the turbo events to have the new page properly loaded.

const formData = new FormData(this.mediumUploadFormTarget);
formData.set(, blob, filename);
const response = await fetch(this.mediumUploadFormTarget.action, {
    method: this.mediumUploadFormTarget.method,
    body: formData,
// do what it takes to have the body (html) properly rendered

Is there an easier way to handle this if you need to support older iOS versions?