Package ipfs.gomobile.android
Class IPFS
- java.lang.Object
-
- ipfs.gomobile.android.IPFS
-
public class IPFS extends java.lang.ObjectIPFS is a class that wraps a go-ipfs node and its shell over UDS.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classIPFS.ConfigCreationExceptionstatic classIPFS.ConfigGettingExceptionstatic classIPFS.ConfigSettingExceptionstatic classIPFS.ExtraOptionExceptionstatic classIPFS.NodeListenExceptionstatic classIPFS.NodeStartExceptionstatic classIPFS.NodeStopExceptionstatic classIPFS.RepoInitExceptionstatic classIPFS.RepoOpenExceptionstatic classIPFS.ShellRequestExceptionstatic classIPFS.SockManagerException
-
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.JSONObjectgetConfig()Gets the IPFS instance config as a JSON.org.json.JSONObjectgetConfigKey(java.lang.String key)Gets the JSON value associated to the key passed as parameter in the IPFS instance config.java.lang.StringgetRepoAbsolutePath()Returns the repo absolute path as a string.booleanisStarted()Returns true if this IPFS instance is "started" by checking if the underlying go-ipfs node is instantiated.RequestBuildernewRequest(java.lang.String command)Creates and returns a RequestBuilder associated to this IPFS instance shell.voidrestart()Restarts this IPFS instance.java.lang.StringserveGatewayMultiaddr(java.lang.String multiaddr, java.lang.Boolean writable)Serves node gateway over the given multiaddrvoidsetConfig(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.voidsetConfigKey(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.voidstart()Starts this IPFS instance.voidstop()Stops this IPFS instance.
-
-
-
Constructor Detail
-
IPFS
public IPFS(@NonNull android.content.Context context) throws IPFS.ConfigCreationException, IPFS.RepoInitException, IPFS.SockManagerExceptionClass constructor using defaultRepoPath "/ipfs/repo" on internal storage.- Parameters:
context- The application context- Throws:
IPFS.ConfigCreationException- If the creation of the config failedIPFS.RepoInitException- If the initialization of the repo failedIPFS.SockManagerException- If the initialization of SockManager failed
-
IPFS
public IPFS(@NonNull android.content.Context context, @NonNull java.lang.String repoPath) throws IPFS.ConfigCreationException, IPFS.RepoInitException, IPFS.SockManagerExceptionClass constructor using repoPath passed as parameter on internal storage.- Parameters:
context- The application contextrepoPath- The path of the go-ipfs repo (relative to internal root)- Throws:
IPFS.ConfigCreationException- If the creation of the config failedIPFS.RepoInitException- If the initialization of the repo failedIPFS.SockManagerException- If the initialization of SockManager failed
-
IPFS
public IPFS(@NonNull android.content.Context context, @NonNull java.lang.String repoPath, boolean internalStorage) throws IPFS.ConfigCreationException, IPFS.RepoInitException, IPFS.SockManagerExceptionClass constructor using repoPath and storage location passed as parameters.- Parameters:
context- The application contextrepoPath- The path of the go-ipfs repo (relative to internal/external root)internalStorage- true, if the desired storage location for the repo path is internal false, if the desired storage location for the repo path is external- Throws:
IPFS.ConfigCreationException- If the creation of the config failedIPFS.RepoInitException- If the initialization of the repo failedIPFS.SockManagerException- If the initialization of SockManager failed
-
-
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.NodeStartExceptionStarts 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
-
stop
public void stop() throws IPFS.NodeStopExceptionStops this IPFS instance.- Throws:
IPFS.NodeStopException- If the node is already stopped or if its stop fails
-
restart
public void restart() throws IPFS.NodeStopExceptionRestarts this IPFS instance.- Throws:
IPFS.NodeStopException- If the node is already stopped or if its stop fails
-
getConfig
public org.json.JSONObject getConfig() throws IPFS.ConfigGettingExceptionGets the IPFS instance config as a JSON.- Returns:
- The IPFS instance config as a JSON
- Throws:
IPFS.ConfigGettingException- If the getting of the config failed- See Also:
- IPFS Config Doc
-
setConfig
public void setConfig(org.json.JSONObject config) throws IPFS.ConfigSettingExceptionSets 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.ConfigGettingExceptionGets 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.ConfigSettingExceptionSets 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 configvalue- 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.NodeListenExceptionServes node gateway over the given multiaddr- Parameters:
multiaddr- The multiaddr to listen onwritable- 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
-
-