We’re kicking off working on an IPFS module for Drupal, with our long time friends here in Vancouver, the Affinity Bridge team.
I posted on Drupal.org that we’re starting this, and will be keeping that thread up to date.
Floyd did some research into the existing IPFS modules / source code listed in that thread. Here are his initial notes:
BurdaMagazinOrg/module-ipfs
Latest commit on Jul 13, 2017
Relies on a library “ipfs/php-stream-wrapper”: “dev-master” which lives at GitHub - treehouse-roots/php-ipfs-stream-wrapper: PHP Stream Wrapper for IPFS and was authored by amateescu, the same guy who authored the other module. That library was last modified on Jun 10, 2018.
Provides an image formatter:
Embeds the image with a weird base64 tag=:
<img data-ipfs-src-base64="Qmf6nyWdmdebpxMLpsWnwJsWefo927F1udJTixHLQ33zHu" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" width="6000" height="4000" alt="Camels" typeof="foaf:Image">
It includes a JS file ipfs.dist.min.js that presumably is another third party library but I am not certain which. There are at least a couple it could be.
Hard coded in the ipfs.dist.min.js file are IP addresses and URLs. As you can see above, the images never appear for me because it cannot connect to /libp2p-webrtc-star/dns4/star-signal.cloud.ipfs.team/wss
, which appears to be a signal server. I don’t yet understand what that means and whether we can change it or should update this library.
This one appears to use an AssetDumper to sync files to the IPFS. I’m unfamiliar with what that is, just see IpfsAssetDumper extends AssetDumper in the code.
amateescu/ipfs
Latest commit on Jun 11, 2018
Provides integration with IPFS via a stream wrapper.
The recommended usage is to configure file or image fields to use IPFS as the upload destination. Image styles are supported for image fields, and the public schema will be used to store the image variations.
The IPFS module doesn’t provide any visible functions to the user on its own, it simply exposes a new stream wrapper to Drupal.
When configuring a field using this module, the administrator selects Upload destination: IPFS.
When saving the nodes, the files appear to get uploaded to the IPFS if the field is set to IPFS. This is similar to the way the S3 module works.
As the user viewing the node, the image gets displayed with an ipfs:// URI like ipfs://QmNyCjDi3Q2a6JfJHfatfjTeUP3gQMNSKXZzCHgAE4SFmz/gilles-desjardins-VT5_jp-Naqs-unsplash.jpg
As you can see in this screenshot, Chrome doesn’t know how to interpret ipfs://
URLs. Maybe Firefox does? I’ll have to check. It also can get the image to show up if I request that URL by itself with the IPFS Companion Chrome plugin enabled. So this may be something that requires a plugin for now but that that IPFS supporters are anticipating being built into browsers some day.
Other notes
Both modules are called ipfs, so they cannot be run concurrently.
I’m not sure how either of these help us with Fission as my impression is that Fission provides a REST API that hides most of the messy IPFS stuff behind http.
Of the two, the second (amateescu/ipfs) is more the way the S3 module works than the first. The first uses an AssetDumper to push assets (everything?) up and retains a mapping table to get from fid or css file name to the IPFS identifier.