Repository navigation
[swift6] Send raw Data multipart parts as files - #25191
Merged
4brunu merged 1 commit intoOct 9, 2026
Merged
Conversation
The alamofire and urlsession libraries appended a raw Data multipart value with only a name, so servers expecting a file upload (a part with a filename) didn't receive one. Add filename (the parameter name) and Content-Type: application/octet-stream to Data parts; String, number and UUID values stay plain form fields. Update swift6 samples.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #21444; complements #22456.
A raw
Datamultipart value was appended with only aname, so servers expecting a file upload (a part with afilename, e.g.$_FILESin PHP orMultipartFilein Spring) didn't receive a file.Dataparts now getfilename(the parameter name) andContent-Type: application/octet-stream:mpForm.append(data, withName: k, fileName: k, mimeType: "application/octet-stream")configureDataUploadRequesttakes optionalfileName/mimeType, passed only forDatavaluesString, number andUUIDvalues stay plain form fields.URLvalues keep their existing file handling.Verified with the generated default (urlsession) sample by capturing the request body through an
OpenAPIInterceptor: the body for["file": Data(...), "note": "hello"]now containsname="file"; filename="file"withContent-Type: application/octet-stream, andname="note"unchanged. The alamofire variant has been running in a downstream client against a PHP backend. The default and alamofireLibrary samples build.Note: until #22456 lands, generated API methods still base64-encode
Dataform params before they reach the builder (viaasParameter). This change takes effect for every rawDatavalue that reaches the builder, and for all of them once #22456 is merged.PR checklist
Summary by cubic
Raw
Datamultipart values were sent as plain form fields, so servers expecting a file upload (a part with afilename) didn't receive one.Dataparts now includefilename(the parameter name) andContent-Type: application/octet-streamin both the alamofire and urlsession libraries, whileString, number, andUUIDvalues stay plain form fields.Written for commit ef8ec9b. Summary will update on new commits.