@aragonone/ipfs-pinner-client
v1.0.1
Published
This is a client library for integrating into other projects.
Downloads
11
Keywords
Readme
Client
This is a client library for integrating into other projects.
Installation
yarn add @aragonone/ipfs-pinner-client
Usage
import client from '@aragonone/ipfs-pinner-client'
// upload and get file metadata
fileMeta = await client.upload(ethAddress, content, fileName)
// get single file
fileMeta = await client.findOne(cid)
// get multiple files
fileMetaPage = await client.findAll(owner, page, pageSize)
// delete IPFS pin and metadata
deleteStatus = await client.delete(cid, signature, timestamp)
For type information see ./src/index.ts
For usage in server integration tests see: ../server/test/integration/file-creation.test.ts
Error handling
import { client, PinnerError } from '@aragonone/ipfs-pinner-client'
try {
fileMeta = await client.upload(ethAddress, content, fileName)
}
catch (err) {
if (err instanceof PinnerError) {
pinnerErrors = err.errors
}
}
If server is unreachable:
pinnerErrors = [{ endpoint: `Could not connect to endpoint (<MESSAGE>)` }]
Server error responses are documented in ../server