Class IPFS


  • public class IPFS
    extends java.lang.Object
    This class represents uploading and getting file from IPFS.
    • Constructor Summary

      Constructors 
      Constructor Description
      IPFS()  
      IPFS​(java.lang.String host, int port, boolean ssl)
      Creates an IPFS instance.
      IPFS​(java.lang.String host, int port, boolean ssl, IPFSOptions options)
      Creates an IPFS instance.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String add​(byte[] content)
      Add byte array to IPFS.
      java.lang.String add​(java.lang.String path)
      Add file to IPFS.
      static java.lang.String fromHex​(java.lang.String hexString)
      Encode hex string with Base58 algorithm.
      byte[] get​(java.lang.String encodedHash)
      Get file from IPFS.
      void setIPFSNode​(java.lang.String host, int port, boolean ssl)
      Set a IPFS node.
      void setIPFSNode​(java.lang.String host, int port, boolean ssl, IPFSOptions options)
      Set a IPFS node.
      static java.lang.String toHex​(java.lang.String encodedHash)
      Decode encoded multi hash string with Base58 and add hex prefix(0x).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • IPFS

        public IPFS()
      • IPFS

        public IPFS​(java.lang.String host,
                    int port,
                    boolean ssl)
        Creates an IPFS instance.
        Parameters:
        host - The host url.
        port - The port number to use.
        ssl - either using ssl or not.
      • IPFS

        public IPFS​(java.lang.String host,
                    int port,
                    boolean ssl,
                    IPFSOptions options)
        Creates an IPFS instance.
        Parameters:
        host - The host url.
        port - The port number to use.
        ssl - either using ssl or not.
        options - An object contains configuration variables.
    • Method Detail

      • toHex

        public static java.lang.String toHex​(java.lang.String encodedHash)
        Decode encoded multi hash string with Base58 and add hex prefix(0x).
        Parameters:
        encodedHash - A encoded string with Base58.
        Returns:
        String
      • fromHex

        public static java.lang.String fromHex​(java.lang.String hexString)
        Encode hex string with Base58 algorithm.
        Parameters:
        hexString - A hex string to encode.
        Returns:
        String
      • add

        public java.lang.String add​(java.lang.String path)
                             throws java.io.IOException
        Add file to IPFS.
        Parameters:
        path - A file path to add at IPFS.
        Returns:
        String
        Throws:
        java.io.IOException
      • add

        public java.lang.String add​(byte[] content)
                             throws java.io.IOException
        Add byte array to IPFS.
        Parameters:
        content - A byte array to add at IPFS
        Returns:
        String
        Throws:
        java.io.IOException
      • get

        public byte[] get​(java.lang.String encodedHash)
                   throws java.io.IOException
        Get file from IPFS.
        Parameters:
        encodedHash - A encoded multi hash string with base58.
        Returns:
        byte[]
        Throws:
        java.io.IOException
      • setIPFSNode

        public void setIPFSNode​(java.lang.String host,
                                int port,
                                boolean ssl)
        Set a IPFS node.
        Parameters:
        host - The host url.
        port - The port number to use.
        ssl - either using ssl or not.
      • setIPFSNode

        public void setIPFSNode​(java.lang.String host,
                                int port,
                                boolean ssl,
                                IPFSOptions options)
        Set a IPFS node.
        Parameters:
        host - The host url.
        port - The port number to use.
        ssl - either using ssl or not.
        options - An object contains configuration variables.