Two weeks ago, I was on the lookout for a service that allowed me to easily download photos for sample purposes in a Kirby CMS theme.

I was surprised by how hard it was. I just needed a zip file, filled with royalty free, reasonably sized, compressed photos. Ones that are, you know… likely to be found on a decent website.

I immediately went to Unsplash. “Free high quality photos… perfect,” I thought, but disliked having to download the images one by one. I wanted a bunch of photos and didn’t care that much about their content. Don’t get me wrong, though, I love photography, but at the time, I just needed anything that wasn’t a gray rectangle with numbers on it.

In Google, I searched for “free images zip” and stuff like that, but found nothing. Then, I stumbled upon Bulksplash. It was just the tool I needed — download images from Unsplash in bulk. I was pleased, until I tried to use it.

That program had some issues

Whenever I tried to download images, I would get ECONNRESET errors. I start the program, download half an image and boom. Error.

I opened an issue on GitHub and asked for help. The error I was getting was unhandled, so I handled it and committed my change. It was slightly better. Now, the program would at least not crash and download 2 out of the 15 photos I request. It was still pretty annoying because I would have over 10 images after each download that are damaged and therefore useless. And to top it all off, every request would download the files with the exact same filename image-N.jpg where N is an integer ranging from 0 to the number of photos you request. This meant new photos would overwrite old ones…

Huge respect for Mehedi Hassan because he inspired me, but he could have done things better. Initially, I thought to just improve the code of Bulksplash. Then, I realized I could make my own thing and even take it a step further.

So I decided to make my own program

CLI tools are not for everybody and I suppose downloading free images is something wanted by more than just web developers. I thought that turning this service into a website would be far better. You would have a graphical interface for options, you wouldn’t have to install anything… just a single button click and you have what you want. Besides, downloading could be handled by a server.

And here’s where the cable joins the action…

I kept getting those ECONNRESET errors and didn’t know why. I researched and researched, but nothing… I just couldn’t fix it. Then, as I was casually talking about it with my brother (who is a Technical Support Engineer), he said my ethernet cable could be causing the problem.

I looked at the cable and it was just a wire with no coating, left unfixed by the ISP gentlemen. I thought “oooh, yeeeah, hardware is a thing.”

How this changed my development process

My brother told me the absence of coating could cause all kinds of disturbances, and apparently it did. This meant that if I wanted proper functionality, I had to make everything bulletproof. When I make a request to the Unsplash API, I need to check and handle errors. When I download each and every photo, I need to check and handle errors. If an error occurs, I need to retry downloading the image…

These are things I don’t usually think about. If it works — it works. But this time, I had to take them into account. I knew that the server where I would deploy my app (powered by Heroku) would probably have decent cabling and these errors would vanish (and I was correct), but I wanted to deploy a tool that I know works. So I put the extra effort and did stuff the right way.

All of that resulted in the creation of Unsample:

Conclusion

If I had a good ethernet cable, I would have probably implemented next to no error handling. Actually… I wouldn’t have even developed Unsample in the first place. I would have just downloaded my sample photos with Bulksplash and be done with it.

In case you missed the links above, you can visit Unsample here or check it on Product Hunt. Big thanks to the team behind Unsplash for making this possible and especially Stephanie Liverani for her incredible support and courtesy.