Drupal IPFS module research

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:


Latest commit on Jul 13, 2017

Relies on a library “ipfs/php-stream-wrapper”: “dev-master” which lives at https://github.com/treehouse-roots/php-ipfs-stream-wrapper 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.


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.

Thanks Floyd for doing this research. We talked about this directly already, just capturing it publicly too :slight_smile:

I’d like the initial scope to be getting this working with the Fission Web API, with a configurable IPFS gateway, which can also default to the Fission one so everything “just works”.

So on output, rather than data URIs or ipfs protocol, we’ll just do “regular” http links using the configured gateway.

Definitely want to get into loading js-ipfs into the browser client side, which can be a configuration, but that’s step 2.

Looks like learning from the S3 module will make the most sense. I understand in Drupal the desire to have lots of config and setting per field, but I think we should focus on simplicity first: when enabled, all files uploaded anywhere in Drupal are store in IPFS instead.

Thanks for this research!

1 Like