3 ms·
Side note: LOC for the example API call in JS: 13 Python: 9 Curl/Bash: 1 Swift: 60
by FabHK 5y ago
Side note:
LOC for the example API call in
JS: 13
Python: 9
Curl/Bash: 1
Swift: 60
- orf 5y agoWhere is this? 9 lines for Python seems excessive. Should surely only be two, one of which is an import?
- FabHK 5y agoIn the "How does it work" section at the bottom. You're right, Python could be much shorter, it defines a few variables for prettiness.
- Daedren 5y agoIt'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.