# java-ipfs-http-client
**Repository Path**: laolianglovecode/java-ipfs-http-client
## Basic Information
- **Project Name**: java-ipfs-http-client
- **Description**: A Java implementation of the HTTP IPFS API
- **Primary Language**: Unknown
- **License**: MIT
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2020-10-25
- **Last Updated**: 2021-11-02
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# java-ipfs-http-client
[](http://ipn.io)
[](http://ipfs.io/)
[](http://webchat.freenode.net/?channels=%23ipfs)
[](https://github.com/RichardLitt/standard-readme)

> A Java client for the IPFS http api
## Table of Contents
- [Install](#install)
- [Usage](#usage)
- [Building](#building)
- [Contribute](#contribute)
- [License](#license)
## Install
### Official releases
You can use this project by including `ipfs.jar` from one of the [releases](https://github.com/ipfs/java-ipfs-api/releases) along with the dependencies.
### Maven, Gradle, SBT
Package managers are supported through [JitPack](https://jitpack.io/#ipfs/java-ipfs-http-client/) which supports Maven, Gradle, SBT, etc.
for Maven, add the following sections to your pom.xml (replacing $LATEST_VERSION):
```
jitpack.io
https://jitpack.io
com.github.ipfs
java-ipfs-http-client
$LATEST_VERSION
```
### Building
* Clone this repository
* Run `ant dist`
* Copy `dist/ipfs.jar` into your project. Appropriate versions of other [dependencies](#dependencies) are also included in `dist/lib/`.
* Run tests using `ant test`.
### Running tests
To run tests, IPFS daemon must be running on `127.0.0.1` interface.
### IPFS installation
#### Command line
Download ipfs from https://dist.ipfs.io/#go-ipfs and run with `ipfs daemon --enable-pubsub-experiment`
#### Docker Compose
Run `docker-compose up` from the project's root directory. Check [docker-compose.yml](docker-compose.yml) for more details.
## Usage
Create an IPFS instance with:
```Java
IPFS ipfs = new IPFS("/ip4/127.0.0.1/tcp/5001");
```
Then run commands like:
```Java
ipfs.refs.local();
```
To add a file use (the add method returns a list of merklenodes, in this case there is only one element):
```Java
NamedStreamable.FileWrapper file = new NamedStreamable.FileWrapper(new File("hello.txt"));
MerkleNode addResult = ipfs.add(file).get(0);
```
To add a byte[] use:
```Java
NamedStreamable.ByteArrayWrapper file = new NamedStreamable.ByteArrayWrapper("hello.txt", "G'day world! IPFS rocks!".getBytes());
MerkleNode addResult = ipfs.add(file).get(0);
```
To get a file use:
```Java
Multihash filePointer = Multihash.fromBase58("QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB");
byte[] fileContents = ipfs.cat(filePointer);
```
## Dependencies
Current versions of dependencies are included in the `./lib` directory.
* [multibase](https://github.com/multiformats/java-multibase)
* [multiaddr](https://github.com/multiformats/java-multiaddr)
* [multihash](https://github.com/multiformats/java-multihash)
* [cid](https://github.com/ipld/java-cid)
## Contribute
Feel free to join in. All welcome. Open an [issue](https://github.com/ipfs/java-ipfs-api/issues)!
This repository falls under the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md).
[](https://github.com/ipfs/community/blob/master/contributing.md)
## License
[MIT](LICENSE)