Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It's very misleading that the author decided to use external libraries on the other examples, yet used the built-in URLSession on Swift.


My swift is pretty rusty now, but I'm fairly sure you don't need to construct an http request by hand (which is what the example code is doing), even if you're limited to only using Foundation classes


The issue is the multipart/form-data body. You still need to build it by hand in current Swift.


The JS fetch example is native, no library. But point taken - what does a Swift file upload request look like with a (common) library?


You can find an example using Alamofire, the most commonly used network framework, here.

https://github.com/Alamofire/Alamofire/blob/master/Documenta...




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: