Optional fileUpload

Hello! A form comes to me from the frontend, in which there are fields and a file (s).
My steps are like this:

                  formFields("name") { (name) =>
                    fileUpload("photo") {
                      case (metadata, byteSource) =>

But, the file field is optional. When it’s not there, I get the following error:
Request is missing required form field 'photo'

Unfortunately, on the Internet, I did not find how to solve this situation, I will be glad for your help.

Hi @arvkonstantin,

multipart/form-field requests are tricky to handle because form fields and upload data can be mixed freely in one stream and akka-http tries to avoid loading all data into memory for random access to fields. There’s no ready made solution for your problem but our documentation has some examples how to access and process the stream of all parts of the request here: