No commit activity in last 3 years
No release in over 3 years
The paperclip storage library to save files on IPFS network.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.0
~> 2.3.5
~> 3.12

Runtime

~> 0.3.0
 Project Readme

Paperclip IPFS Storage

This gem extends the Paperclip so that you can save file on IPFS network.

Installation

gem "paperclip-ipfs-storage"

or put it on the Gemfile.

Usage

Add attachment type field into the schema as usual, then add string type field as [field_name]_ipfs_hash. For example:

class CreateMediaAttachments < ActiveRecord::Migration[5.0]
  def change
    create_table :media_attachments do |t|
      t.attachment :file
      t.string :file_ipfs_hash, :file_ipfs_hash, null: true, default: nil
    end
  end
end

Then specify :ipfs for the :storage option and ':gateway_url' for the :url in the model. For example:

class MediaAttachment < ActiveRecord::Base
  has_attached_file :file,
    :storage => :ipfs,
    :url => ':gateway_url'
end

Limitation

You cannot remove the file uploaded. This is due to the design of IPFS 1.

Footnotes

  1. https://github.com/ipfs/faq/issues/9