# IPFS HTTP CLIENT

Dive into the specifics of connecting and using IPFS HTTP CLIENT with web3stash

## Initialization

To use IPFS HTTP Client which actually allows you to connect to local or your own hosted ipfs providers you have to pass "IPFS-CLIENT" as the service name. No other name will work!

```javascript
const ipfsClientService = Web3Stash("IPFS-CLIENT",{url:{}},{IPFS-Http-Client APIconfig options})
```

## Configuration&#x20;

To use IPFS Http Client in web3stash, you need one thing:

* url- URL to connect to ipfs node

There are multiple ways of passing url-

```
// connect to ipfs daemon API server
const url = 'http://localhost:5001'

// or connect with multiaddr
const url = '/ip4/127.0.0.1/tcp/5001'

// or using options
const url = { host: 'localhost', port: '5001', protocol: 'http', headers:{} }

// or specifying a specific API path
const url = { host: '1.1.1.1', port: '80', apiPath: '/ipfs/api/v0' }


const ipfsClientService = Web3Stash("IPFS-CLIENT",{url:url})

```



Note: Use these names only while passing keys in objects i.e, {url:"",}

#### Optional Config Options

There are no configOptions for this service

## Methods Available

The following methods are available for this service, More will be added soon

* Uploading JSON data&#x20;

```javascript
ipfsClientService.uploadJson({name:"example", url:"abc.com"}, {ipfsClientOptions}).then().catch()
```

* Uploading Image

```javascript
ipfsClientService.uploadImage("./image.png", {ipfsClientOptions}).then().catch()
```

* Uploading Video

```javascript
ipfsClientService.uploadVideo("./video.mp4", {ipfsClientOptions}).then().catch()
```

* Uploading File

<pre class="language-javascript"><code class="lang-javascript"><strong>ipfsClientService.uploadFile("./data.txt", {ipfsClientOptions}).then().catch()
</strong></code></pre>



## Output

All the functions return id (cid) and metadata (data returned by the service on upload)

<pre class="language-javascript"><code class="lang-javascript"><strong>{id:"dewfnlpweurmwknrwiojhgcbxczz", metadata:{}}
</strong></code></pre>
