Class IPFS


  • public class IPFS
    extends java.lang.Object
    IPFS is a class that wraps a go-ipfs node and its shell over UDS.
    • Constructor Summary

      Constructors 
      Constructor Description
      IPFS​(android.content.Context context)
      Class constructor using defaultRepoPath "/ipfs/repo" on internal storage.
      IPFS​(android.content.Context context, java.lang.String repoPath)
      Class constructor using repoPath passed as parameter on internal storage.
      IPFS​(android.content.Context context, java.lang.String repoPath, boolean internalStorage)
      Class constructor using repoPath and storage location passed as parameters.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.json.JSONObject getConfig()
      Gets the IPFS instance config as a JSON.
      org.json.JSONObject getConfigKey​(java.lang.String key)
      Gets the JSON value associated to the key passed as parameter in the IPFS instance config.
      java.lang.String getRepoAbsolutePath()
      Returns the repo absolute path as a string.
      boolean isStarted()
      Returns true if this IPFS instance is "started" by checking if the underlying go-ipfs node is instantiated.
      RequestBuilder newRequest​(java.lang.String command)
      Creates and returns a RequestBuilder associated to this IPFS instance shell.
      void restart()
      Restarts this IPFS instance.
      java.lang.String serveGatewayMultiaddr​(java.lang.String multiaddr, java.lang.Boolean writable)
      Serves node gateway over the given multiaddr
      void setConfig​(org.json.JSONObject config)
      Sets JSON config passed as parameter as IPFS config or reset to default config (with a new identity) if the config parameter is null.
      A started instance must be restarted for its config to be applied.
      void setConfigKey​(java.lang.String key, org.json.JSONObject value)
      Sets JSON config value to the key passed as parameters in the IPFS instance config.
      A started instance must be restarted for its config to be applied.
      void start()
      Starts this IPFS instance.
      void stop()
      Stops this IPFS instance.
      • Methods inherited from class java.lang.Object

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

      • getRepoAbsolutePath

        public java.lang.String getRepoAbsolutePath()
        Returns the repo absolute path as a string.
        Returns:
        The repo absolute path
      • isStarted

        public boolean isStarted()
        Returns true if this IPFS instance is "started" by checking if the underlying go-ipfs node is instantiated.
        Returns:
        true, if this IPFS instance is started
      • start

        public void start()
                   throws IPFS.NodeStartException
        Starts this IPFS instance. Also serve config Gateway and API located inside the config (if any)
        Throws:
        IPFS.NodeStartException - If the node is already started or if its startup fails
      • setConfig

        public void setConfig​(org.json.JSONObject config)
                       throws IPFS.ConfigSettingException
        Sets JSON config passed as parameter as IPFS config or reset to default config (with a new identity) if the config parameter is null.
        A started instance must be restarted for its config to be applied.
        Parameters:
        config - The IPFS instance JSON config to set (if null, default config will be used)
        Throws:
        IPFS.ConfigSettingException - If the setting of the config failed
        See Also:
        IPFS Config Doc
      • getConfigKey

        public org.json.JSONObject getConfigKey​(@NonNull
                                                java.lang.String key)
                                         throws IPFS.ConfigGettingException
        Gets the JSON value associated to the key passed as parameter in the IPFS instance config.
        Parameters:
        key - The key associated to the value to get in the IPFS config
        Returns:
        The JSON value associated to the key passed as parameter in the IPFS instance config
        Throws:
        IPFS.ConfigGettingException - If the getting of the config value failed
        See Also:
        IPFS Config Doc
      • setConfigKey

        public void setConfigKey​(@NonNull
                                 java.lang.String key,
                                 @NonNull
                                 org.json.JSONObject value)
                          throws IPFS.ConfigSettingException
        Sets JSON config value to the key passed as parameters in the IPFS instance config.
        A started instance must be restarted for its config to be applied.
        Parameters:
        key - The key associated to the value to set in the IPFS instance config
        value - The JSON value associated to the key to set in the IPFS instance config
        Throws:
        IPFS.ConfigSettingException - If the setting of the config value failed
        See Also:
        IPFS Config Doc
      • newRequest

        public RequestBuilder newRequest​(@NonNull
                                         java.lang.String command)
                                  throws IPFS.ShellRequestException
        Creates and returns a RequestBuilder associated to this IPFS instance shell.
        Parameters:
        command - The command of the request
        Returns:
        A RequestBuilder based on the command passed as parameter
        Throws:
        IPFS.ShellRequestException - If this IPFS instance is not started
        See Also:
        IPFS API Doc
      • serveGatewayMultiaddr

        public java.lang.String serveGatewayMultiaddr​(@NonNull
                                                      java.lang.String multiaddr,
                                                      @NonNull
                                                      java.lang.Boolean writable)
                                               throws IPFS.NodeListenException
        Serves node gateway over the given multiaddr
        Parameters:
        multiaddr - The multiaddr to listen on
        writable - If true: will also support support `POST`, `PUT`, and `DELETE` methods.
        Returns:
        The MultiAddr the node is serving on
        Throws:
        IPFS.NodeListenException - If the node failed to serve
        See Also:
        IPFS Doc