I am trying to upload a couple of files in a multipart/form-data request. The files are being populated to Request.Files but ServiceStack.Host.HttpFile does not have a Name property, so I have no way to identify the field that each upload represents.
So from the multipart request below, the names lightLogo & darkLogo isn’t obtainable from the Files collection:
Only the the FileName property is available, which is what we use in HTTP Apache Benchmarks. This is all that’s available in the underlying ASP.NET HttpPostedFile Type which is also what’s used by the HttpListener Request.
If you need the name in addition to the FileName, one way to send it is via the QueryString, e.g:
Posting the filenames separately like that would require assurances from the client that it was going to always post the multipart segments in that particular order. But looking through the source code, the data is available from the multipart in both platforms, it’s just not exposed to Mono.
I am looking at ListenerRequest.Mono.cs and can see that the HttpMultipart.Element has e.Name … where e.Name would be the multipart field name and this is passed into HttpFileCollection files, and it’s this collection that is used by ListenerRequest.cs to populate the IHttpFile[] property on the request. So wouldn’t the field name then be available there?
Wouldn’t exposing HttpFileCollection on ListenerRequest.Mono provide the desired filenames?
If I was on ASP.NET I could check Request.OriginalRequest.Files.Keys but on Mono I can’t.