Hacker News new | ask | show | jobs
by capableweb 1153 days ago
But also, if you're just making two API calls (the use case for Linen) which are using JSON, you can get both request making and json parsing pretty much out-of-the-box without doing anything, web browsers JS API ships with this by default, window.fetch and response.json(), no "building your own HTTP client" required :)

You need to have two calls at least, generate a signed URL and then actually uploading it. How many lines on the client would you guess that requires? My guess is less than 30, and you cover 100% of your use case without putting in any 3rd party code what so ever. Sounds like a solid win with few drawbacks.

3 comments

That's a good trick for JSON-based AWS APIs, but the S3 API is all XML AFAIK. I had to fix some signing bugs in the unofficial Haskell AWS SDK, and found it rather fiddly and a fair bit more than 30 LoC. Compared to standard AWS SigV4, S3 is also a special case in a few ways (request chunking, support for presigned PUTs with unsigned payloads, etc).
Ah, good point, but of course the browser also ships with APIs for dealing with XML, not doing so would be weird as HTML and the XML structure a pretty fundamental part of the web. See XMLHttpRequest, XMLSerializer and DOMParser.
If you are using pre-signed urls, or public objects, then there is really no reason you need to use an s3 library, any old http client will work fine. But if you need to authenticate the request yourself, then you have to deal with the somewhat complicated process of signing the url, headers and body, if applicable. It isn't terrible, but it is probably more than you want to do if you have a library available.
What about retries, status code handling, timeouts, and backoff? (It's not a lot of code to add that stuff in but I still call it a "client".)
AWS doesn’t do that for you either.
yes it does, to some extent e.g., retries https://boto3.amazonaws.com/v1/documentation/api/latest/guid...
You linked the Python SDK, just FYI. Here’s the JavaScript version: https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clien...