3 ms·
It's very misleading that the author decided to use external libraries on the other examples, yet used the built-in URLSession on Swift.
by Daedren 5y ago
It's very misleading that the author decided to use external libraries on the other examples, yet used the built-in URLSession on Swift.
- stickfigure 5y agoThe JS fetch example is native, no library. But point taken - what does a Swift file upload request look like with a (common) library?
- Daedren 5y agoYou can find an example using Alamofire, the most commonly used network framework, here. https://github.com/Alamofire/Alamofire/blob/master/Documentation/Usage.md#uploading-data-to-a-server https://github.com/Alamofire/Alamofire/blob/master/Documenta...
- yen223 5y agoMy 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
- Daedren 5y agoThe issue is the multipart/form-data body. You still need to build it by hand in current Swift.