Skip to content

ipfs/helia-remote-pinning

Repository files navigation

@helia/remote-pinning

ipfs.tech Discuss codecov CI

A library that helps Helia users pin content via the IPFS pinning-services-api-spec

Table of contents

Install

$ npm i @helia/remote-pinning

Browser <script> tag

Loading this module through a script tag will make it's exports available as HeliaRemotePinning in the global namespace.

<script src="https://unpkg.com/@helia/remote-pinning/dist/index.min.js"></script>

Documentation

Create remote pinner

import { unixfs } from '@helia/unixfs'
import { Configuration, RemotePinningServiceClient } from '@ipfs-shipyard/pinning-service-client'
import { createHelia } from 'helia'
import { createRemotePinner } from '@helia/remote-pinning'

const helia = await createHelia()
const pinServiceConfig = new Configuration({
  endpointUrl: `${endpointUrl}`, // the URI for your pinning provider, e.g. `http://localhost:3000`
  accessToken: `${accessToken}` // the secret token/key given to you by your pinning provider
})

const remotePinningClient = new RemotePinningServiceClient(pinServiceConfig)
const remotePinner = createRemotePinner(helia, remotePinningClient)

Add a pin

const heliaFs = unixfs(helia)
const cid = await heliaFs.addBytes(encoder.encode('hello world'))
const addPinResult = await remotePinner.addPin({
  cid,
  name: 'helloWorld'
})

Replace a pin

const newCid = await heliaFs.addBytes(encoder.encode('hi galaxy'))
const replacePinResult = await remotePinner.replacePin({
  newCid,
  name: 'hiGalaxy',
  requestid: addPinResult.requestid
})

Lead Maintainer

SgtPooki

Contributing

Contributions are welcome! This repository is part of the IPFS project and therefore governed by our contributing guidelines.

License

Licensed under either of

Contribute

Contributions welcome! Please check out the issues.

Also see our contributing document for more information on how we work, and about contributing in general.

Please be aware that all interactions related to this repo are subject to the IPFS Code of Conduct.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.