InterPlanetary File System (IPFS) is a protocol created in 2013 that introduces the idea of distributing the content in a decentralized manner using constant hashes (related: Content Addressable Storage) and not url locations that can mutate over time. So, instead of having data stored in a centralized location, IPFS spreads it around the world, which changes how we can consume and store information online.
Combining IPFS and tools like cURL seems like a match made in heaven, and as such the curl team have done a great work trying to integrate IPFS upstream.
While cURL's official release with IPFS support in #8805 is planned for next month, we won’t make you wait for it.
Thanks to cURL being compiled to WebAssembly using WASIX, developers can already harness the power of IPFS and Curl using Wasmer. In this article, we'll introduce you to two basic examples, offering a preview of the exciting potential that lies within cURL’s IPFS functionalities when executed via WebAssembly and Wasmer.
Minimum version required: 4.2.1
You can install the Wasmer Runtime using the following command:
curl https://get.wasmer.io -sSfL | sh
This first example is from one of the cURL’s #8805 comment.
$ wasmer run curl/curl --net --env IPFS_GATEWAY=https://ipfs.io -- ipfs://bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am hello
Now let’s download the movie big buck bunny using IPFS.
$ wasmer run curl/curl --net --env IPFS_GATEWAY=https://ipfs.io --mapdir /output:. -- ipfs://bafybeigagd5nmnn2iys2f3doro7ydrevyr2mzarwidgadawmamiteydbzi --output ./output/res.mp4 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 159M 100 159M 0 0 7994k 0 0:00:20 0:00:20 --:--:-- 9478k
The above command will download the big buck bunny video and output in your current folder with the name
🚧 The video is playable via VLC
The above examples showcase the ease of using WASIX based modules and sandboxing capabilities of WebAssembly. How you can try out the latest features of cURL without having to wait for the official release. You don’t need to compile/build anything and it just works for almost every platform out there.
📺 Seeing it in action
Example 1: Hello World
Example 2: Downloading Buck Bunny movie
Syrus AkbaryJuly 17, 2023
Syrus AkbaryApril 18, 2023
Syrus AkbaryJune 2, 2021
Arshia GhafooriSeptember 7, 2023