Package com.klaytn.caver.ipfs.wrapper
Class IPFSWrapper
- java.lang.Object
-
- com.klaytn.caver.ipfs.wrapper.IPFSWrapper
-
public class IPFSWrapper extends java.lang.Object
Representing an IPFSWrapper 1. This class should be accessed through `caver.ipfs` 2. This class wraps all public methods (including static methods) of IPFS
-
-
Constructor Summary
Constructors Constructor Description IPFSWrapper()
Creates an IPFSWrapper instance
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
add(byte[] content)
Add byte array to IPFSjava.lang.String
add(java.lang.String path)
Add file to IPFS.IPFSOptions
createOptions(java.lang.String projectId, java.lang.String projectSecret)
Create an IPFSOptions object that includes `"Authorization"` made from `projectId` and `projectSecret`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 an IPFS node with IPFSOptions instance.java.lang.String
toHex(java.lang.String encodedHash)
Decode encoded multi hash string with Base58 and add hex prefix(0x).
-
-
-
Method Detail
-
toHex
public 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 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 an IPFS node with IPFSOptions instance.Example:
IPFSOptions options = caver.ipfs.createOptions(this.projectId, this.projectSecret); caver.ipfs.setIPFSNode("ipfs.infura.io", 5001, true, options);
- Parameters:
host
- The host url.port
- The port number to use.ssl
- either using ssl or not.options
- An object contains configuration variables.
-
createOptions
public IPFSOptions createOptions(java.lang.String projectId, java.lang.String projectSecret)
Create an IPFSOptions object that includes `"Authorization"` made from `projectId` and `projectSecret`Example :
IPFSOptions options = caver.ipfs.createOptions(this.projectId, this.projectSecret);
- Parameters:
projectId
- The project id string.projectSecret
- The project secret string.
-
-