Skip to content

How to use in backend site. (Express, Fastify, NestJS) #84

@truongly1997

Description

@truongly1997

Hi pinata engineer

We provide an API to every upload their image. Then our backend application will integrate with pinata by using pinata-web3 like the code below

  @AppCatch(Pinata_ERROR.STREAM_TO_IPFS_FAILED)
  async streamToIPFS(chunks: Readable, _metadata: PinataMetadata = {}, _groupId?: string) {
    try {
      const ipfs = await this.pinata.upload.stream(chunks, { cidVersion: 1, ..._metadata })
      return ipfs
    } catch (error) {
      this.logger.error('streaming to IPFS failed: ', error)
    }
  }

it working well but lately, when our tester try to upload same image twice times. The second always return undefined instead of object

      "hash": "bafybeicap2pomrxztny73st6d6h5nutiryrquu5dykwrfvessjyclgzm5u",
      "size": 4062722,
      "time": "2025-06-03T05:31:05.018Z",
      "isDuplicate": true

So that we reading documentation and try to implement the example follow the quickstart https://docs.pinata.cloud/frameworks/node-js

Image

If you have an document guide how to upload from backend site please give us to following

Thank and best regards

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions