A library that helps Helia users pin content via the IPFS pinning-services-api-spec
$ npm i @helia/remote-pinning
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>
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)
const heliaFs = unixfs(helia)
const cid = await heliaFs.addBytes(encoder.encode('hello world'))
const addPinResult = await remotePinner.addPin({
cid,
name: 'helloWorld'
})
const newCid = await heliaFs.addBytes(encoder.encode('hi galaxy'))
const replacePinResult = await remotePinner.replacePin({
newCid,
name: 'hiGalaxy',
requestid: addPinResult.requestid
})
Contributions are welcome! This repository is part of the IPFS project and therefore governed by our contributing guidelines.
Licensed under either of
- Apache 2.0, (LICENSE-APACHE / http://www.apache.org/licenses/LICENSE-2.0)
- MIT (LICENSE-MIT / http://opensource.org/licenses/MIT)
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.