Open yousifalraheem opened 2 months ago
Hey @yousifalraheem. We have an example package for client and server that show how to handle various request and response content types, including multipart here: https://github.com/apple/swift-openapi-generator/tree/main/Examples/various-content-types-client-example.
If that doesn't help, let us know and we can take a closer look at your use case specifically.
Hi @yousifalraheem,
it seems you're manually serializing the multipart part, but that's not correct - the generated code already does that. You need to simplify your Data creation to just:
func imageToMultipartData(_ image: UIImage) async throws -> Data {
image.jpegData(compressionQuality: 1.0)!
}
Hi @yousifalraheem - were you able to get it working?
Question
I'm using your package to generate my APIs which has been working great for me. However, as soon as I started working with uploading files, I stumbled upon an issue with
multipart/form-data
. Whenever I use the generated API, it sends the request with the file having a mimetype ofapplication/octet-stream
. Which is something that I am not supporting on the backend nor do I have plans to do so. If I'm uploading a jpeg image, I expect the mimetype to beimage/jpeg
. How do I get this desired behavior?This is how I create data from a UIImage:
This is how I'm using the generated API:
This is my schema for the method:
Where
UploadImageDto
component have this schema: